Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

91 řádky
2.8KB

  1. #!/usr/bin/env php
  2. <?php
  3. /**
  4. * This file is part of CodeIgniter 4 framework.
  5. *
  6. * (c) CodeIgniter Foundation <admin@codeigniter.com>
  7. *
  8. * For the full copyright and license information, please view
  9. * the LICENSE file that was distributed with this source code.
  10. */
  11. /*
  12. * --------------------------------------------------------------------
  13. * CodeIgniter command-line tools
  14. * --------------------------------------------------------------------
  15. * The main entry point into the CLI system and allows you to run
  16. * commands and perform maintenance on your application.
  17. *
  18. * Because CodeIgniter can handle CLI requests as just another web request
  19. * this class mainly acts as a passthru to the framework itself.
  20. */
  21. // Refuse to run when called from php-cgi
  22. if (strpos(PHP_SAPI, 'cgi') === 0) {
  23. exit("The cli tool is not supported when running php-cgi. It needs php-cli to function!\n\n");
  24. }
  25. // We want errors to be shown when using it from the CLI.
  26. error_reporting(-1);
  27. ini_set('display_errors', '1');
  28. /**
  29. * @var bool
  30. *
  31. * @deprecated No longer in use. `CodeIgniter` has `$context` property.
  32. */
  33. define('SPARKED', true);
  34. // Path to the front controller
  35. define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR);
  36. // Ensure the current directory is pointing to the front controller's directory
  37. chdir(FCPATH);
  38. /*
  39. *---------------------------------------------------------------
  40. * BOOTSTRAP THE APPLICATION
  41. *---------------------------------------------------------------
  42. * This process sets up the path constants, loads and registers
  43. * our autoloader, along with Composer's, loads our constants
  44. * and fires up an environment-specific bootstrapping.
  45. */
  46. // Load our paths config file
  47. // This is the line that might need to be changed, depending on your folder structure.
  48. require FCPATH . '../app/Config/Paths.php';
  49. // ^^^ Change this line if you move your application folder
  50. $paths = new Config\Paths();
  51. // Location of the framework bootstrap file.
  52. require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
  53. // Load environment settings from .env files into $_SERVER and $_ENV
  54. require_once SYSTEMPATH . 'Config/DotEnv.php';
  55. (new CodeIgniter\Config\DotEnv(ROOTPATH))->load();
  56. // Grab our CodeIgniter
  57. $app = Config\Services::codeigniter();
  58. $app->initialize();
  59. $app->setContext('spark');
  60. // Grab our Console
  61. $console = new CodeIgniter\CLI\Console($app);
  62. // Show basic information before we do anything else.
  63. if (is_int($suppress = array_search('--no-header', $_SERVER['argv'], true))) {
  64. unset($_SERVER['argv'][$suppress]); // @codeCoverageIgnore
  65. $suppress = true;
  66. }
  67. $console->showHeader($suppress);
  68. // fire off the command in the main framework.
  69. $response = $console->run();
  70. if ($response->getStatusCode() >= 300) {
  71. exit($response->getStatusCode());
  72. }