|
3 | 3 |
|
4 | 4 | use App\Kernel; |
5 | 5 | use Symfony\Bundle\FrameworkBundle\Console\Application; |
6 | | -use Symfony\Component\Console\Input\ArgvInput; |
7 | 6 | use Symfony\Component\Debug\Debug; |
8 | | -use Symfony\Component\Dotenv\Dotenv; |
9 | 7 |
|
10 | 8 | set_time_limit(0); |
11 | 9 |
|
12 | | -require __DIR__.'/../vendor/autoload.php'; |
| 10 | +require dirname(__DIR__).'/vendor/autoload.php'; |
13 | 11 |
|
14 | 12 | if (!class_exists(Application::class)) { |
15 | 13 | throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.'); |
16 | 14 | } |
17 | 15 |
|
18 | | -if (!isset($_SERVER['APP_ENV'])) { |
19 | | - if (!class_exists(Dotenv::class)) { |
20 | | - throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.'); |
21 | | - } |
22 | | - (new Dotenv())->load(__DIR__.'/../.env'); |
23 | | -} |
24 | | - |
25 | | -$input = new ArgvInput(); |
26 | | -$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev', true); |
27 | | -$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption('--no-debug', true); |
| 16 | +Kernel::bootstrapCli($_SERVER['argv']); |
| 17 | +Kernel::bootstrapEnv(); |
28 | 18 |
|
29 | | -if ($debug) { |
| 19 | +if ($_SERVER['APP_DEBUG']) { |
30 | 20 | umask(0000); |
31 | 21 |
|
32 | 22 | if (class_exists(Debug::class)) { |
33 | 23 | Debug::enable(); |
34 | 24 | } |
35 | 25 | } |
36 | 26 |
|
37 | | -$kernel = new Kernel($env, $debug); |
| 27 | +$kernel = new Kernel($_SERVER['APP_ENV'], $_SERVER['APP_DEBUG']); |
38 | 28 | $application = new Application($kernel); |
39 | | -$application->run($input); |
| 29 | +$application->run(); |
0 commit comments