]> BookStack Code Mirror - system-cli/blob - scripts/Services/EnvironmentLoader.php
Updated env loading to be contained/controlled for usage
[system-cli] / scripts / Services / EnvironmentLoader.php
1 <?php
2
3 namespace Cli\Services;
4
5 use Dotenv\Dotenv;
6
7 class EnvironmentLoader
8 {
9     public static function load(string $rootPath): array
10     {
11         $dotenv = Dotenv::createArrayBacked($rootPath);
12         return $dotenv->safeLoad();
13     }
14
15     public static function loadMergedWithCurrentEnv(string $rootPath): array
16     {
17         $env = static::load($rootPath);
18         foreach ($_SERVER as $key => $val) {
19             $env[$key] = $val;
20         }
21         return $env;
22     }
23 }