diff --git a/src/Illuminate/Support/helpers.php b/src/Illuminate/Support/helpers.php index d3312cfc73e9..4cea4963bed1 100755 --- a/src/Illuminate/Support/helpers.php +++ b/src/Illuminate/Support/helpers.php @@ -8,6 +8,7 @@ use Dotenv\Environment\DotenvFactory; use Illuminate\Contracts\Support\Htmlable; use Illuminate\Support\HigherOrderTapProxy; +use Dotenv\Environment\Adapter\PutenvAdapter; use Dotenv\Environment\Adapter\EnvConstAdapter; use Dotenv\Environment\Adapter\ServerConstAdapter; @@ -642,7 +643,7 @@ function env($key, $default = null) static $variables; if ($variables === null) { - $variables = (new DotenvFactory([new EnvConstAdapter, new ServerConstAdapter]))->createImmutable(); + $variables = (new DotenvFactory([new EnvConstAdapter, new PutEnvAdapter, new ServerConstAdapter]))->createImmutable(); } return Option::fromValue($variables->get($key)) diff --git a/tests/Foundation/Bootstrap/LoadEnvironmentVariablesTest.php b/tests/Foundation/Bootstrap/LoadEnvironmentVariablesTest.php index da65d1000fbb..bbc21270f6de 100644 --- a/tests/Foundation/Bootstrap/LoadEnvironmentVariablesTest.php +++ b/tests/Foundation/Bootstrap/LoadEnvironmentVariablesTest.php @@ -37,6 +37,9 @@ public function testCanLoad() (new LoadEnvironmentVariables)->bootstrap($this->getAppMock('.env')); $this->assertSame('BAR', env('FOO')); + $this->assertSame('BAR', getenv('FOO')); + $this->assertSame('BAR', $_ENV['FOO']); + $this->assertSame('BAR', $_SERVER['FOO']); } public function testCanFailSilent()