From 98b0d404dcc6d9552e07fb0d4764bd9615c84e8c Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 8 May 2022 07:30:48 +0900 Subject: [PATCH] refactor: move chdir() up --- public/index.php | 8 +++++--- spark | 7 ++++--- system/bootstrap.php | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/public/index.php b/public/index.php index 33601ff9b1b1..51f4be81e731 100644 --- a/public/index.php +++ b/public/index.php @@ -3,6 +3,9 @@ // Path to the front controller (this file) define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR); +// Ensure the current directory is pointing to the front controller's directory +chdir(FCPATH); + /* *--------------------------------------------------------------- * BOOTSTRAP THE APPLICATION @@ -12,9 +15,6 @@ * and fires up an environment-specific bootstrapping. */ -// Ensure the current directory is pointing to the front controller's directory -chdir(FCPATH); - // Load our paths config file // This is the line that might need to be changed, depending on your folder structure. require FCPATH . '../app/Config/Paths.php'; @@ -38,6 +38,7 @@ * the application run, and does all of the dirty work to get * the pieces all working together. */ + $app = Config\Services::codeigniter(); $app->initialize(); $context = is_cli() ? 'php-cli' : 'web'; @@ -50,4 +51,5 @@ * Now that everything is setup, it's time to actually fire * up the engines and make this app do its thang. */ + $app->run(); diff --git a/spark b/spark index fd453e84ce25..225422aace74 100755 --- a/spark +++ b/spark @@ -40,6 +40,9 @@ define('SPARKED', true); // Path to the front controller define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR); +// Ensure the current directory is pointing to the front controller's directory +chdir(FCPATH); + /* *--------------------------------------------------------------- * BOOTSTRAP THE APPLICATION @@ -49,9 +52,6 @@ define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR) * and fires up an environment-specific bootstrapping. */ -// Ensure the current directory is pointing to the front controller's directory -chdir(FCPATH); - // Load our paths config file // This is the line that might need to be changed, depending on your folder structure. require FCPATH . '../app/Config/Paths.php'; @@ -66,6 +66,7 @@ require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstra require_once SYSTEMPATH . 'Config/DotEnv.php'; (new CodeIgniter\Config\DotEnv(ROOTPATH))->load(); +// Grab our CodeIgniter $app = Config\Services::codeigniter(); $app->initialize(); $app->setContext('spark'); diff --git a/system/bootstrap.php b/system/bootstrap.php index 7fae1a2a417e..fec0e5c14b02 100644 --- a/system/bootstrap.php +++ b/system/bootstrap.php @@ -66,6 +66,7 @@ * GRAB OUR CONSTANTS & COMMON * --------------------------------------------------------------- */ + if (! defined('APP_NAMESPACE')) { require_once APPPATH . 'Config/Constants.php'; }