codysnider /
tt-rss
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | use RssApp\Controller; |
||
| 6 | use RssApp\Bootstrap; |
||
| 7 | use RssApp\RequestBootstrap; |
||
| 8 | use Spiral\Debug; |
||
|
0 ignored issues
–
show
|
|||
| 9 | |||
| 10 | define("BASEPATH", dirname(__FILE__)); |
||
| 11 | define("DS", DIRECTORY_SEPARATOR); |
||
| 12 | |||
| 13 | require_once BASEPATH.DS.'external'.DS.'autoload.php'; |
||
| 14 | |||
| 15 | define("APPLICATION_ENV", getenv("APPLICATION_ENV") ?? 'dev'); |
||
| 16 | |||
| 17 | $dumper = new Debug\Dumper(); |
||
| 18 | $dumper->setRenderer(Debug\Dumper::ERROR_LOG, new Debug\Renderer\ConsoleRenderer()); |
||
| 19 | function dump($msg) { |
||
| 20 | global $dumper; |
||
| 21 | $dumper->dump($msg, Debug\Dumper::ERROR_LOG); |
||
| 22 | } |
||
| 23 | |||
| 24 | try { |
||
| 25 | Bootstrap::initialize(); |
||
| 26 | } catch (Exception $e) { |
||
| 27 | echo "Problem with application bootstrap: ".$e->getMessage(); |
||
| 28 | } |
||
| 29 | |||
| 30 | $relay = new Spiral\Goridge\StreamRelay(STDIN, STDOUT); |
||
| 31 | $psr7 = new Spiral\RoadRunner\PSR7Client(new Spiral\RoadRunner\Worker($relay)); |
||
| 32 | while ($req = $psr7->acceptRequest()) { |
||
| 33 | try { |
||
| 34 | RequestBootstrap::initialize(); |
||
| 35 | $resp = Controller::handle(); |
||
| 36 | $psr7->respond($resp); |
||
| 37 | } catch (Throwable $e) { |
||
| 38 | $psr7->getWorker()->error((string) $e); |
||
| 39 | } |
||
| 40 | } |
||
| 41 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: