Add support for .env files
This commit is contained in:
parent
f08ff2307a
commit
7a3b093cf7
1 changed files with 14 additions and 0 deletions
|
|
@ -11,7 +11,21 @@ class EnvironmentService
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->environmentVariables = array_merge($_SERVER, $_ENV);
|
$this->environmentVariables = array_merge($_SERVER, $_ENV);
|
||||||
|
if(file_exists(APP_ROOT . '/.env')){
|
||||||
|
$env = file_get_contents(APP_ROOT . '/.env');
|
||||||
|
$lines = explode("\n", $env);
|
||||||
|
foreach($lines as $line){
|
||||||
|
$line = trim($line);
|
||||||
|
if($line == ''){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$parts = explode('=', $line);
|
||||||
|
$this->environmentVariables[$parts[0]] = $parts[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ksort($this->environmentVariables);
|
ksort($this->environmentVariables);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function has(string $key): bool
|
public function has(string $key): bool
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue