|
1 | 1 | #!/usr/bin/env php
|
2 | 2 | <?php
|
3 | 3 |
|
4 |
| -declare(strict_types=1); |
5 |
| - |
| 4 | +use Tests\Acme\SyliusExamplePlugin\Application\Kernel; |
6 | 5 | use Symfony\Bundle\FrameworkBundle\Console\Application;
|
7 | 6 | use Symfony\Component\Console\Input\ArgvInput;
|
8 | 7 | use Symfony\Component\Debug\Debug;
|
9 |
| -use Symfony\Component\Dotenv\Dotenv; |
10 |
| -use Tests\Acme\SyliusExamplePlugin\Application\Kernel; |
11 | 8 |
|
12 | 9 | set_time_limit(0);
|
13 | 10 |
|
14 | 11 | require __DIR__.'/../../../vendor/autoload.php';
|
15 | 12 |
|
16 | 13 | if (!class_exists(Application::class)) {
|
17 |
| - throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.'); |
| 14 | + throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.'); |
18 | 15 | }
|
19 | 16 |
|
20 |
| -if (!isset($_SERVER['APP_ENV'])) { |
21 |
| - if (!class_exists(Dotenv::class)) { |
22 |
| - 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.'); |
23 |
| - } |
| 17 | +$input = new ArgvInput(); |
| 18 | +if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) { |
| 19 | + putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); |
| 20 | +} |
24 | 21 |
|
25 |
| - $envFile = file_exists(__DIR__.'/../.env') ? __DIR__.'/../.env' : __DIR__.'/../.env.dist'; |
26 |
| - (new Dotenv())->load($envFile); |
| 22 | +if ($input->hasParameterOption('--no-debug', true)) { |
| 23 | + putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); |
27 | 24 | }
|
28 | 25 |
|
29 |
| -$input = new ArgvInput(); |
30 |
| -$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev', true); |
31 |
| -$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption('--no-debug', true); |
| 26 | +require dirname(__DIR__).'/config/bootstrap.php'; |
32 | 27 |
|
33 |
| -if ($debug) { |
| 28 | +if ($_SERVER['APP_DEBUG']) { |
34 | 29 | umask(0000);
|
35 | 30 |
|
36 | 31 | if (class_exists(Debug::class)) {
|
37 | 32 | Debug::enable();
|
38 | 33 | }
|
39 | 34 | }
|
40 | 35 |
|
41 |
| -$kernel = new Kernel($env, $debug); |
| 36 | +$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); |
42 | 37 | $application = new Application($kernel);
|
43 | 38 | $application->run($input);
|
0 commit comments