collection-crud/bin/console

40 lines
1.2 KiB
Plaintext
Raw Normal View History

2017-11-09 11:53:01 -05:00
#!/usr/bin/env php
<?php
use App\Kernel;
2017-11-09 11:53:01 -05:00
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
2017-11-30 15:06:13 -05:00
use Symfony\Component\Dotenv\Dotenv;
2017-11-09 11:53:01 -05:00
set_time_limit(0);
require __DIR__.'/../vendor/autoload.php';
2017-11-30 15:06:13 -05:00
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');
}
2017-11-09 11:53:01 -05:00
$input = new ArgvInput();
2017-11-30 15:06:13 -05:00
$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev');
$debug = ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption(['--no-debug', '']);
2017-11-09 11:53:01 -05:00
if ($debug) {
2017-11-30 15:06:13 -05:00
umask(0000);
if (class_exists(Debug::class)) {
Debug::enable();
}
2017-11-09 11:53:01 -05:00
}
2017-11-30 15:06:13 -05:00
$kernel = new Kernel($env, $debug);
2017-11-09 11:53:01 -05:00
$application = new Application($kernel);
$application->run($input);