Commit | Line | Data |
---|---|---|
dec6d031 JB |
1 | #!/usr/bin/env php |
2 | <?php | |
3 | ||
4 | use App\Kernel; | |
5 | use Symfony\Bundle\FrameworkBundle\Console\Application; | |
6 | use Symfony\Component\Console\Input\ArgvInput; | |
7 | use Symfony\Component\Debug\Debug; | |
8 | use Symfony\Component\Dotenv\Dotenv; | |
9 | ||
10 | set_time_limit(0); | |
11 | ||
12 | require __DIR__.'/../vendor/autoload.php'; | |
13 | ||
14 | if (!class_exists(Application::class)) { | |
15 | throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.'); | |
16 | } | |
17 | ||
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); | |
28 | ||
29 | if ($debug) { | |
30 | umask(0000); | |
31 | ||
32 | if (class_exists(Debug::class)) { | |
33 | Debug::enable(); | |
34 | } | |
35 | } | |
36 | ||
37 | $kernel = new Kernel($env, $debug); | |
38 | $application = new Application($kernel); | |
39 | $application->run($input); |