I don't use environment variables a lot, but According to the PHP docs, it looks like anything in the $ENV superglobal has to start with "PHP", so in order to access it via $_ENV you may need to call it "PHP_database_host".
Well the $_ENV does work if you have a .env.xxx.php file, it just doesnt seem to come further if you use a virtualhost for it. $SERVER is also a superglobal, if i call that instead it works just fine. But i want to keep the code the same and use $_ENV everywhere instead of having this one setup use something else.
Why not use something like this?
'host' => (getenv('database_host') !== false) ? getenv('database_host') : 'localhost',
Duh, should have thought of that. I got it working now. So now i dont need a .env.xxxx.php file.. only to find out that if you run your migrations it will not use the virtualhost and cannot set the values.
Anyways the reason is when i publish my stuff to prod i first clean the directory where it goes to. This also deletes my .env.xxx.php file so i wanted a sollution that would stick when wiped.
I'll mark above as solution from thepsion, since that was the question. But i did find another solution, its a bit cheezy but hey some solutions are. I just chmod 444 the .env.xxx.php file, so it doesn't get deleted but still works.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community