mirror of
https://github.com/symfony/recipes.git
synced 2026-09-20 19:46:52 +03:00
- look for the --env and --no-debug only before a -- separator, to respect the support for -- - avoid passing an empty string as parameter option name (which would never match anyway, but causes php warning is some Symfony versions instead of being ignored silently).
40 lines
1.2 KiB
PHP
Executable File
40 lines
1.2 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
|
|
use App\Kernel;
|
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
|
use Symfony\Component\Console\Input\ArgvInput;
|
|
use Symfony\Component\Debug\Debug;
|
|
use Symfony\Component\Dotenv\Dotenv;
|
|
|
|
set_time_limit(0);
|
|
|
|
require __DIR__.'/../vendor/autoload.php';
|
|
|
|
if (!class_exists(Application::class)) {
|
|
throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
|
|
}
|
|
|
|
if (!isset($_SERVER['APP_ENV'])) {
|
|
if (!class_exists(Dotenv::class)) {
|
|
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.');
|
|
}
|
|
(new Dotenv())->load(__DIR__.'/../.env');
|
|
}
|
|
|
|
$input = new ArgvInput();
|
|
$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev', true);
|
|
$debug = ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption('--no-debug', true);
|
|
|
|
if ($debug) {
|
|
umask(0000);
|
|
|
|
if (class_exists(Debug::class)) {
|
|
Debug::enable();
|
|
}
|
|
}
|
|
|
|
$kernel = new Kernel($env, $debug);
|
|
$application = new Application($kernel);
|
|
$application->run($input);
|