|
3 | 3 |
|
4 | 4 | use App\Kernel;
|
5 | 5 | use Symfony\Bundle\FrameworkBundle\Console\Application;
|
6 |
| -use Symfony\Component\Console\Input\ArgvInput; |
7 |
| -use Symfony\Component\Dotenv\Dotenv; |
8 |
| -use Symfony\Component\ErrorHandler\Debug; |
9 | 6 |
|
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; |
| 7 | +if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) { |
| 8 | + throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".'); |
12 | 9 | }
|
13 | 10 |
|
14 |
| -set_time_limit(0); |
| 11 | +require_once dirname(__DIR__).'/vendor/autoload_runtime.php'; |
15 | 12 |
|
16 |
| -require dirname(__DIR__).'/vendor/autoload.php'; |
| 13 | +return function (array $context) { |
| 14 | + $kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); |
17 | 15 |
|
18 |
| -if (!class_exists(Application::class) || !class_exists(Dotenv::class)) { |
19 |
| - throw new LogicException('You need to add "symfony/framework-bundle" and "symfony/dotenv" as Composer dependencies.'); |
20 |
| -} |
21 |
| - |
22 |
| -$input = new ArgvInput(); |
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 |
| -(new Dotenv())->bootEnv(dirname(__DIR__).'/.env'); |
32 |
| - |
33 |
| -if ($_SERVER['APP_DEBUG']) { |
34 |
| - umask(0000); |
35 |
| - |
36 |
| - if (class_exists(Debug::class)) { |
37 |
| - Debug::enable(); |
38 |
| - } |
39 |
| -} |
40 |
| - |
41 |
| -$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); |
42 |
| -$application = new Application($kernel); |
43 |
| -$application->run($input); |
| 16 | + return new Application($kernel); |
| 17 | +}; |
0 commit comments