spark 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. * --------------------------------------------------------------------
  5. * CodeIgniter command-line tools
  6. * --------------------------------------------------------------------
  7. * The main entry point into the CLI system and allows you to run
  8. * commands and perform maintenance on your application.
  9. *
  10. * Because CodeIgniter can handle CLI requests as just another web request
  11. * this class mainly acts as a passthru to the framework itself.
  12. */
  13. define('SPARKED', true);
  14. /*
  15. *---------------------------------------------------------------
  16. * BOOTSTRAP THE APPLICATION
  17. *---------------------------------------------------------------
  18. * This process sets up the path constants, loads and registers
  19. * our autoloader, along with Composer's, loads our constants
  20. * and fires up an environment-specific bootstrapping.
  21. */
  22. // Refuse to run when called from php-cgi
  23. if (strpos(php_sapi_name(), 'cgi') === 0)
  24. {
  25. die("The cli tool is not supported when running php-cgi. It needs php-cli to function!\n\n");
  26. }
  27. // Path to the front controller
  28. define('FCPATH', __DIR__ . '/public' . DIRECTORY_SEPARATOR);
  29. // Load our paths config file
  30. require 'app/Config/Paths.php';
  31. // ^^^ Change this line if you move your application folder
  32. $paths = new Config\Paths();
  33. // Ensure the current directory is pointing to the front controller's directory
  34. chdir(FCPATH);
  35. $app = require rtrim($paths->systemDirectory, '/ ') . '/bootstrap.php';
  36. // Grab our Console
  37. $console = new \CodeIgniter\CLI\Console($app);
  38. // We want errors to be shown when using it from the CLI.
  39. error_reporting(-1);
  40. ini_set('display_errors', 1);
  41. // Show basic information before we do anything else.
  42. $console->showHeader();
  43. // fire off the command in the main framework.
  44. $response = $console->run();
  45. if ($response->getStatusCode() >= 300)
  46. {
  47. exit($response->getStatusCode());
  48. }