getenv() will not work with vlucas/phpdotenv
when set "disable_functions=putenv" at php.ini
disable_functions=putenv
you could be check by phpinfo()
some.env
SOMETHING=OK
code.php
Dotenv::create("some.env")->load();
var_dump(getenv("SOMETHING")); => false
var_dump($_ENV["SOMETHING"]); => "OK"
Got NO runtime errors. because getenv
is not disabled actually.
vlucas/phpdotenv
will be check available method/function.
- https://github.com/vlucas/phpdotenv/blob/13be13df7df1ba7bca099b16943a8ba025a38a02/src/Environment/DotenvFactory.php#L34
- https://github.com/vlucas/phpdotenv/blob/4f26ad74566ff980adbfa2e33594bad318cd1aa5/src/Environment/Adapter/PutenvAdapter.php#L16
But, Didn't check getenv (that is right design, I thought).
woooo....
function _getenv($name){
if(getenv($name) !== false) return getenv($name);
else if(isset($_ENV[$name])) return $_ENV[$name];
else return false;
}
# or, replace getenv to $_ENV
umm....