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