diff --git a/symfony/framework-bundle/3.3/config/bootstrap.php b/symfony/framework-bundle/3.3/config/bootstrap.php index 10ab2f46f..2a471864d 100644 --- a/symfony/framework-bundle/3.3/config/bootstrap.php +++ b/symfony/framework-bundle/3.3/config/bootstrap.php @@ -4,14 +4,14 @@ require dirname(__DIR__).'/vendor/autoload.php'; +if (!class_exists(Dotenv::class)) { + throw new LogicException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); +} + // Load cached env vars if the .env.local.php file exists // Run "composer dump-env prod" to create it (requires symfony/flex >=1.2) -if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV'] ?? null) === ($env['APP_ENV'] ?? null)) { - foreach ($env as $k => $v) { - $_ENV[$k] = $_ENV[$k] ?? (isset($_SERVER[$k]) && 0 !== strpos($k, 'HTTP_') ? $_SERVER[$k] : $v); - } -} elseif (!class_exists(Dotenv::class)) { - throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); +if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && (!isset($env['APP_ENV']) || ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV'])) { + (new Dotenv(false))->populate($env); } else { $path = dirname(__DIR__).'/.env'; $dotenv = new Dotenv(false); diff --git a/symfony/framework-bundle/4.2/config/bootstrap.php b/symfony/framework-bundle/4.2/config/bootstrap.php index 3164fd1c6..55560fb83 100644 --- a/symfony/framework-bundle/4.2/config/bootstrap.php +++ b/symfony/framework-bundle/4.2/config/bootstrap.php @@ -4,14 +4,14 @@ require dirname(__DIR__).'/vendor/autoload.php'; +if (!class_exists(Dotenv::class)) { + throw new LogicException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); +} + // Load cached env vars if the .env.local.php file exists // Run "composer dump-env prod" to create it (requires symfony/flex >=1.2) if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && (!isset($env['APP_ENV']) || ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV'])) { - foreach ($env as $k => $v) { - $_ENV[$k] = $_ENV[$k] ?? (isset($_SERVER[$k]) && 0 !== strpos($k, 'HTTP_') ? $_SERVER[$k] : $v); - } -} elseif (!class_exists(Dotenv::class)) { - throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); + (new Dotenv(false))->populate($env); } else { // load all the .env files (new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env');