mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
refactor: move CodeIgniter::bootstrapEnvironment() to bootstrap.php
This commit is contained in:
parent
470dace722
commit
4e602a66f3
@ -36,18 +36,20 @@ require FCPATH . '../app/Config/Paths.php';
|
||||
|
||||
$paths = new Config\Paths();
|
||||
|
||||
// Location of the framework bootstrap file.
|
||||
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
|
||||
|
||||
// Load environment settings from .env files into $_SERVER and $_ENV
|
||||
require_once SYSTEMPATH . 'Config/DotEnv.php';
|
||||
(new CodeIgniter\Config\DotEnv(ROOTPATH))->load();
|
||||
require_once $paths->systemDirectory . '/Config/DotEnv.php';
|
||||
(new CodeIgniter\Config\DotEnv($paths->appDirectory . '/../'))->load();
|
||||
|
||||
// Define ENVIRONMENT
|
||||
if (! defined('ENVIRONMENT')) {
|
||||
define('ENVIRONMENT', env('CI_ENVIRONMENT', 'production'));
|
||||
$env = $_ENV['CI_ENVIRONMENT'] ?? $_SERVER['CI_ENVIRONMENT'] ?? getenv('CI_ENVIRONMENT');
|
||||
define('ENVIRONMENT', ($env !== false) ? $env : 'production');
|
||||
unset($env);
|
||||
}
|
||||
|
||||
// Location of the framework bootstrap file.
|
||||
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
|
||||
|
||||
// Load Config Cache
|
||||
// $factoriesCache = new \CodeIgniter\Cache\FactoriesCache();
|
||||
// $factoriesCache->load('config');
|
||||
|
14
spark
14
spark
@ -64,18 +64,20 @@ require FCPATH . '../app/Config/Paths.php';
|
||||
|
||||
$paths = new Config\Paths();
|
||||
|
||||
// Location of the framework bootstrap file.
|
||||
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
|
||||
|
||||
// Load environment settings from .env files into $_SERVER and $_ENV
|
||||
require_once SYSTEMPATH . 'Config/DotEnv.php';
|
||||
(new CodeIgniter\Config\DotEnv(ROOTPATH))->load();
|
||||
require_once $paths->systemDirectory . '/Config/DotEnv.php';
|
||||
(new CodeIgniter\Config\DotEnv($paths->appDirectory . '/../'))->load();
|
||||
|
||||
// Define ENVIRONMENT
|
||||
if (! defined('ENVIRONMENT')) {
|
||||
define('ENVIRONMENT', env('CI_ENVIRONMENT', 'production'));
|
||||
$env = $_ENV['CI_ENVIRONMENT'] ?? $_SERVER['CI_ENVIRONMENT'] ?? getenv('CI_ENVIRONMENT');
|
||||
define('ENVIRONMENT', ($env !== false) ? $env : 'production');
|
||||
unset($env);
|
||||
}
|
||||
|
||||
// Location of the framework bootstrap file.
|
||||
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
|
||||
|
||||
// Grab our CodeIgniter
|
||||
$app = Config\Services::codeigniter();
|
||||
$app->initialize();
|
||||
|
@ -186,9 +186,6 @@ class CodeIgniter
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
// Define environment variables
|
||||
$this->bootstrapEnvironment();
|
||||
|
||||
// Setup Exception Handling
|
||||
Services::exceptions()->initialize();
|
||||
|
||||
@ -584,6 +581,8 @@ class CodeIgniter
|
||||
* is wrong. At the very least, they should have error reporting setup.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @deprecated 4.5.0 Moved to system/bootstrap.php.
|
||||
*/
|
||||
protected function bootstrapEnvironment()
|
||||
{
|
||||
|
@ -39,6 +39,10 @@ unset($source);
|
||||
require CONFIGPATH . 'Paths.php';
|
||||
$paths = new Paths();
|
||||
|
||||
// Load environment settings from .env files into $_SERVER and $_ENV
|
||||
require_once $paths->systemDirectory . '/Config/DotEnv.php';
|
||||
(new DotEnv($paths->appDirectory . '/../'))->load();
|
||||
|
||||
// Define necessary framework path constants
|
||||
defined('APPPATH') || define('APPPATH', realpath(rtrim($paths->appDirectory, '\\/ ')) . DIRECTORY_SEPARATOR);
|
||||
defined('WRITEPATH') || define('WRITEPATH', realpath(rtrim($paths->writableDirectory, '\\/ ')) . DIRECTORY_SEPARATOR);
|
||||
@ -51,6 +55,11 @@ defined('SUPPORTPATH') || define('SUPPORTPATH', realpath(TESTPATH . '_support/
|
||||
defined('COMPOSER_PATH') || define('COMPOSER_PATH', (string) realpath(HOMEPATH . 'vendor/autoload.php'));
|
||||
defined('VENDORPATH') || define('VENDORPATH', realpath(HOMEPATH . 'vendor') . DIRECTORY_SEPARATOR);
|
||||
|
||||
// Load environment bootstrap
|
||||
if (is_file(APPPATH . 'Config/Boot/' . ENVIRONMENT . '.php')) {
|
||||
require_once APPPATH . 'Config/Boot/' . ENVIRONMENT . '.php';
|
||||
}
|
||||
|
||||
// Load Common.php from App then System
|
||||
if (is_file(APPPATH . 'Common.php')) {
|
||||
require_once APPPATH . 'Common.php';
|
||||
|
@ -53,6 +53,27 @@ if (! defined('TESTPATH')) {
|
||||
define('TESTPATH', realpath(rtrim($paths->testsDirectory, '\\/ ')) . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------------------
|
||||
* LOAD ENVIRONMENT BOOTSTRAP
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* Load any custom boot files based upon the current environment.
|
||||
* If no boot file exists, we shouldn't continue because something
|
||||
* is wrong. At the very least, they should have error reporting setup.
|
||||
*/
|
||||
|
||||
if (is_file(APPPATH . 'Config/Boot/' . ENVIRONMENT . '.php')) {
|
||||
require_once APPPATH . 'Config/Boot/' . ENVIRONMENT . '.php';
|
||||
} else {
|
||||
// @codeCoverageIgnoreStart
|
||||
header('HTTP/1.1 503 Service Unavailable.', true, 503);
|
||||
echo 'The application environment is not set correctly.';
|
||||
|
||||
exit(EXIT_ERROR); // EXIT_ERROR
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------------------
|
||||
* GRAB OUR CONSTANTS & COMMON
|
||||
|
Loading…
x
Reference in New Issue
Block a user