|
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_dir(dirname(__DIR__).'/vendor')) { |
| 8 | + throw new LogicException('Dependencies are missing. Try running "composer install".'); |
12 | 9 | } |
13 | 10 |
|
14 | | -set_time_limit(0); |
15 | | - |
16 | | -require dirname(__DIR__).'/vendor/autoload.php'; |
17 | | - |
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); |
| 11 | +if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) { |
| 12 | + throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".'); |
25 | 13 | } |
26 | 14 |
|
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'); |
| 15 | +require_once dirname(__DIR__).'/vendor/autoload_runtime.php'; |
32 | 16 |
|
33 | | -if ($_SERVER['APP_DEBUG']) { |
34 | | - umask(0000); |
35 | | - |
36 | | - if (class_exists(Debug::class)) { |
37 | | - Debug::enable(); |
38 | | - } |
39 | | -} |
| 17 | +return function (array $context) { |
| 18 | + $kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); |
40 | 19 |
|
41 | | -$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); |
42 | | -$application = new Application($kernel); |
43 | | -$application->run($input); |
| 20 | + return new Application($kernel); |
| 21 | +}; |
0 commit comments