Skip to content

Commit 27567de

Browse files
committed
Fix inconsistency with .env loaders out of the box
PHP .env loaders such as `symfony/dotenv` or `vlucas/phpdotenv` populate `$_SERVER` and `$_ENV` out of the box, but don't call `putenv()` in order to preserve thread safeness. This means .env is loaded by them, but AWS SDK does not read it, creating inconsistent experience when handling real env variables and env variables loaded by these loaders
1 parent e2d3ff9 commit 27567de

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/functions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,6 @@ function getenv(string $name)
608608
{
609609
$out = \getenv($name);
610610

611-
return $out === false ? ($_SERVER[$name] ?? false) : $out;
611+
return $out === false ? ($_ENV[$name] ?? false) : $out;
612612
}
613613

tests/FunctionsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,6 @@ public function getIniFileServiceTestCases()
523523
public function testgetenv()
524524
{
525525
$this->assertEquals(false, Aws\getenv('FOO'));
526-
$this->assertEquals($_SERVER['FOO'] = 'bar', Aws\getenv('FOO'));
526+
$this->assertEquals($_ENV['FOO'] = 'bar', Aws\getenv('FOO'));
527527
}
528528
}

0 commit comments

Comments
 (0)