CodeIgniter4/spark

96 lines
2.8 KiB
Plaintext
Raw Normal View History

#!/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.
*/
/*
* --------------------------------------------------------------------
* 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.
*/
/**
* @var bool
*
* @deprecated No longer in use. `CodeIgniter` has `$context` property.
*/
define('SPARKED', true);
// Path to the front controller
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR);
/*
*---------------------------------------------------------------
* 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.
*/
// Ensure the current directory is pointing to the front controller's directory
chdir(FCPATH);
// Refuse to run when called from php-cgi
2021-06-07 19:06:26 +08:00
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");
}
// This is the line that might need to be changed, depending on your folder structure.
$pathsConfig = FCPATH . '../app/Config/Paths.php';
2019-01-02 19:11:55 -08:00
// ^^^ Change this line if you move your application folder
// Load our paths config file
require $pathsConfig;
2018-12-03 17:31:31 -02:00
$paths = new Config\Paths();
// Location of the framework bootstrap file.
2020-08-26 02:10:30 +08:00
$bootstrap = rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
require $bootstrap;
// Load environment settings from .env files into $_SERVER and $_ENV
require_once SYSTEMPATH . 'Config/DotEnv.php';
$env = new CodeIgniter\Config\DotEnv(ROOTPATH);
$env->load();
$app = Config\Services::codeigniter();
$app->initialize();
$app->setContext('spark');
// Grab our Console
2020-08-26 02:10:30 +08:00
$console = new CodeIgniter\CLI\Console($app);
// We want errors to be shown when using it from the CLI.
error_reporting(-1);
2020-08-26 02:10:30 +08:00
ini_set('display_errors', '1');
// 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);
2019-08-27 14:17:00 -04:00
// fire off the command in the main framework.
$response = $console->run();
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
}