console 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env php
  2. <?php
  3. use App\Kernel;
  4. use Symfony\Bundle\FrameworkBundle\Console\Application;
  5. use Symfony\Component\Console\Input\ArgvInput;
  6. use Symfony\Component\ErrorHandler\Debug;
  7. if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
  8. echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
  9. }
  10. set_time_limit(0);
  11. require dirname(__DIR__).'/vendor/autoload.php';
  12. if (!class_exists(Application::class)) {
  13. throw new LogicException('You need to add "symfony/framework-bundle" as a Composer dependency.');
  14. }
  15. $input = new ArgvInput();
  16. if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
  17. putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
  18. }
  19. if ($input->hasParameterOption('--no-debug', true)) {
  20. putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
  21. }
  22. require dirname(__DIR__).'/config/bootstrap.php';
  23. if ($_SERVER['APP_DEBUG']) {
  24. umask(0000);
  25. if (class_exists(Debug::class)) {
  26. Debug::enable();
  27. }
  28. }
  29. $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
  30. $application = new Application($kernel);
  31. $application->run($input);