Skip to content

Commit

Permalink
refactor: move definition of ENVIRONMENT to index.php/spark
Browse files Browse the repository at this point in the history
For Config caching.
  • Loading branch information
kenjis committed Aug 16, 2023
1 parent f9b95e3 commit db612fa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
require_once SYSTEMPATH . 'Config/DotEnv.php';
(new CodeIgniter\Config\DotEnv(ROOTPATH))->load();

// Define ENVIRONMENT
if (! defined('ENVIRONMENT')) {
define('ENVIRONMENT', env('CI_ENVIRONMENT', 'production'));
}

/*
* ---------------------------------------------------------------
* GRAB OUR CODEIGNITER INSTANCE
Expand Down
5 changes: 5 additions & 0 deletions spark
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstra
require_once SYSTEMPATH . 'Config/DotEnv.php';
(new CodeIgniter\Config\DotEnv(ROOTPATH))->load();

// Define ENVIRONMENT
if (! defined('ENVIRONMENT')) {
define('ENVIRONMENT', env('CI_ENVIRONMENT', 'production'));
}

// Grab our CodeIgniter
$app = Config\Services::codeigniter();
$app->initialize();
Expand Down
3 changes: 2 additions & 1 deletion system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ public function __construct(App $config)
public function initialize()
{
// Define environment variables
$this->detectEnvironment();
$this->bootstrapEnvironment();

// Setup Exception Handling
Expand Down Expand Up @@ -560,6 +559,8 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
* production
*
* @codeCoverageIgnore
*
* @deprecated 4.4.0 No longer used. Moved to index.php and spark.
*/
protected function detectEnvironment()
{
Expand Down

0 comments on commit db612fa

Please sign in to comment.