The getenv()
always returns false. I am using Symfony dotenv library and loading my variables from a .env file in the root of my project.
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\Dotenv\Exception\PathException;
if (!getenv('APP_ENV')) {
try {
(new Dotenv())->load(__DIR__ . '/../.env');
} catch (PathException $ex) {
echo $ex->getMessage();
exit(1);
}
}
var_dump(getenv('APP_ENV')); // bool(false)
But when I dump the super global I can see my variables
var_dump($_ENV); // array:1["APP_ENV" => "dev"]
So what am I missing?