This package provide a way to load .env files values as environement variable, it was insiperd by nodejs counterpart.
This package require php 7.2
With composer:
composer require linna/dotenv
.env.test file as example
APP=linna
APP_ENV=production
[email protected]
FOO=foo
BAR=bar
BAZ=baz
php code for get above values
$env = new Linna\DotEnv\DotEnv();
$env->load('.env.test');
$app = $env->get('APP');
$app_env = $env->get('APP_ENV');
//string 'linna' (length=5)
var_dump($app);
//string 'production' (length=10)
var_dump($app_env);
environment information in phpinfo()
phpinfo(INFO_ENVIRONMENT);
DotEnv class use php function getenv and putenv then
key and values will not be loaded in $_ENV
superglobal.