|
1 | 1 | #!/usr/bin/env php |
2 | 2 | <?php |
3 | 3 |
|
| 4 | +// based on https://github.com/symfony/recipes/blob/984d337aabb837ab5f20322af0290111f98c164a/symfony/console/4.4/bin/console |
| 5 | + |
4 | 6 | use Symfony\Bundle\FrameworkBundle\Console\Application; |
5 | 7 | use Symfony\Component\Console\Input\ArgvInput; |
6 | | -use Symfony\Component\Debug\Debug; |
| 8 | +use Symfony\Component\ErrorHandler\Debug; |
| 9 | + |
| 10 | +if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) { |
| 11 | + echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL; |
| 12 | +} |
7 | 13 |
|
8 | 14 | set_time_limit(0); |
9 | 15 |
|
10 | | -require __DIR__ . '/../vendor/autoload.php'; |
| 16 | +require dirname(__DIR__).'/vendor/autoload.php'; |
| 17 | + |
| 18 | +if (!class_exists(Application::class)) { |
| 19 | + throw new LogicException('You need to add "symfony/framework-bundle" as a Composer dependency.'); |
| 20 | +} |
11 | 21 |
|
12 | 22 | $input = new ArgvInput(); |
13 | | -$env = $input->getParameterOption(['--env', '-e'], getenv('APP_ENV') ?: 'development'); |
14 | | -$debug = getenv('APP_DEBUG') != '0' && !$input->hasParameterOption(['--no-debug', '']); |
| 23 | +if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) { |
| 24 | + putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); |
| 25 | +} |
| 26 | + |
| 27 | +if ($input->hasParameterOption('--no-debug', true)) { |
| 28 | + putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); |
| 29 | +} |
| 30 | + |
| 31 | +require dirname(__DIR__).'/config/bootstrap.php'; |
| 32 | + |
| 33 | +if ($_SERVER['APP_DEBUG']) { |
| 34 | + umask(0000); |
15 | 35 |
|
16 | | -if ($debug) { |
17 | | - Debug::enable(); |
| 36 | + if (class_exists(Debug::class)) { |
| 37 | + Debug::enable(); |
| 38 | + } |
18 | 39 | } |
19 | 40 |
|
20 | | -$kernel = new AppKernel($env, $debug); |
| 41 | +$kernel = new AppKernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); |
21 | 42 | $application = new Application($kernel); |
22 | 43 | $application->run($input); |
0 commit comments