From 2b3e7e2f16313708299858e01338fe9ffc8432a1 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 10 Apr 2019 14:54:53 +0200 Subject: [PATCH] Populate $_SERVER with $_ENV --- symfony/framework-bundle/3.3/config/bootstrap.php | 2 +- symfony/framework-bundle/4.2/config/bootstrap.php | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/symfony/framework-bundle/3.3/config/bootstrap.php b/symfony/framework-bundle/3.3/config/bootstrap.php index 1dab152d..096341bf 100644 --- a/symfony/framework-bundle/3.3/config/bootstrap.php +++ b/symfony/framework-bundle/3.3/config/bootstrap.php @@ -7,7 +7,6 @@ require dirname(__DIR__).'/vendor/autoload.php'; // 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 += $env; $_ENV += $env; } elseif (!class_exists(Dotenv::class)) { throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); @@ -46,6 +45,7 @@ if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) { } } +$_SERVER += $_ENV; $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; $_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV']; $_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0'; diff --git a/symfony/framework-bundle/4.2/config/bootstrap.php b/symfony/framework-bundle/4.2/config/bootstrap.php index d06bd70d..2c52005c 100644 --- a/symfony/framework-bundle/4.2/config/bootstrap.php +++ b/symfony/framework-bundle/4.2/config/bootstrap.php @@ -7,10 +7,6 @@ require dirname(__DIR__).'/vendor/autoload.php'; // 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')) { - foreach ($env as $name => $value) { - putenv("$name=$value"); - } - $_SERVER += $env; $_ENV += $env; } elseif (!class_exists(Dotenv::class)) { throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); @@ -19,6 +15,7 @@ if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) { (new Dotenv())->loadEnv(dirname(__DIR__).'/.env'); } +$_SERVER += $_ENV; $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; $_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV']; $_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';