Skip to content

Commit

Permalink
refactor: move chdir() up
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed May 7, 2022
1 parent 5cba764 commit 98b0d40
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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();
7 changes: 4 additions & 3 deletions spark
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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';
Expand All @@ -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');
Expand Down
1 change: 1 addition & 0 deletions system/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
* GRAB OUR CONSTANTS & COMMON
* ---------------------------------------------------------------
*/

if (! defined('APP_NAMESPACE')) {
require_once APPPATH . 'Config/Constants.php';
}
Expand Down

0 comments on commit 98b0d40

Please sign in to comment.