Skip to content

Commit e2e94e8

Browse files
committed
refactor: move DotEnv::load() from system/bootstrap.php
1 parent b6a27dc commit e2e94e8

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

public/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929

3030
require $bootstrap;
3131

32+
// Load environment settings from .env files into $_SERVER and $_ENV
33+
require_once SYSTEMPATH . 'Config/DotEnv.php';
34+
35+
$env = new CodeIgniter\Config\DotEnv(ROOTPATH);
36+
$env->load();
37+
3238
/*
3339
* ---------------------------------------------------------------
3440
* GRAB OUR CODEIGNITER INSTANCE

spark

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ $bootstrap = rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'boo
6262

6363
require $bootstrap;
6464

65+
// Load environment settings from .env files into $_SERVER and $_ENV
66+
require_once SYSTEMPATH . 'Config/DotEnv.php';
67+
68+
$env = new CodeIgniter\Config\DotEnv(ROOTPATH);
69+
$env->load();
70+
6571
$app = Config\Services::codeigniter();
6672
$app->initialize();
6773
$app->setContext('spark');

system/bootstrap.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* the LICENSE file that was distributed with this source code.
1010
*/
1111

12-
use CodeIgniter\Config\DotEnv;
1312
use Config\Autoload;
1413
use Config\Modules;
1514
use Config\Paths;
@@ -123,11 +122,5 @@ class_alias('Config\Services', 'CodeIgniter\Services');
123122
require_once COMPOSER_PATH;
124123
}
125124

126-
// Load environment settings from .env files into $_SERVER and $_ENV
127-
require_once SYSTEMPATH . 'Config/DotEnv.php';
128-
129-
$env = new DotEnv(ROOTPATH);
130-
$env->load();
131-
132125
// Always load the URL helper, it should be used in most of apps.
133126
helper('url');

0 commit comments

Comments
 (0)