Wednesday, March 29, 2017

Is DotEnv module in Laravel framework going to overwrite existing ENV var in my system?

I'd like to be sure if given a defined ENV variable on my system:

e.g.

$export TEST_VAR=hello

Then installing my laravel application having in .env file

TEST_VAR=goodbye

What would be then the expected behaviour if I try to print

<?php echo $_ENV['TEST_VAR']

I performed some tests and it seems like the .env file definition is not going to override the system defined ENV var. But I'm not sure if it's going to be always like that.

I see on : https://github.com/vlucas/phpdotenv

on Immutability paragraph that:

"By default, Dotenv will NOT overwrite existing environment variables that are already set in the environment.

If you want Dotenv to overwrite existing environment variables, use overload instead of load"

Didn't find so far, where exactly Laravel framework invokes DOtEnv package in order to load/overload env var....



via koalaok

Advertisement