Skip to content

Commit 65dc172

Browse files
committed
ensure is contains real env vars from , or defaults from .env.local.php
1 parent a73014e commit 65dc172

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

symfony/framework-bundle/3.3/config/bootstrap.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
// Load cached env vars if the .env.local.php file exists
88
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
99
if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
10-
$_ENV += $env;
10+
foreach ($env as $k => $v) {
11+
$_ENV[$k] = $_ENV[$k] ?? (isset($_SERVER[$k]) && 0 !== strpos($k, 'HTTP_') ? $_SERVER[$k] : $v);
12+
}
1113
} elseif (!class_exists(Dotenv::class)) {
1214
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
1315
} else {

symfony/framework-bundle/4.2/config/bootstrap.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
// Load cached env vars if the .env.local.php file exists
88
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
99
if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
10-
$_ENV += $env;
10+
foreach ($env as $k => $v) {
11+
$_ENV[$k] = $_ENV[$k] ?? (isset($_SERVER[$k]) && 0 !== strpos($k, 'HTTP_') ? $_SERVER[$k] : $v);
12+
}
1113
} elseif (!class_exists(Dotenv::class)) {
1214
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
1315
} else {

0 commit comments

Comments
 (0)