Sorry, i figured out an explanation for it on Stack Overflow in this discussion: http://stackoverflow.com/questions/32093709/laravel-5-0-33-loads-wrong-env-file/
It turns out that dotevn is only for development instances of the project. In production the config files have to be hardcoded.
"phpdotenv is made for development environments, and generally should not be used in production. In production, the actual environment variables should be set so that there is no overhead of loading the .env file on each request."
I use git on the production instance, so my solution for the problem is to set the environment variables in each vhost file for each instance i need on the server:
SetEnv DB_DATABASE laravel_stage SetEnv CACHE_PREFIX stage
I see you already commented on it :)
I use Laravel 5 and i have the following folders on my server: /var/www/laravel_dev/ /var/www/laravel_stage/ /var/www/laravel_production/
They each have their own .env file and database, but for some reason each of them sometimes loads the wrong .env file (like once every 100th request).
I figured it loads the wrong .env file because when i dump the env database: var_dump(env('DB_DATABSE')); It some times return the name of the laravel_production database on the laravel_dev site.
I have made a grep search for the laravel_production database name, and it's not in the dev folder.
I have triede to dump the dir constant (DIR) various places, it's always correct, and my only solution is to set static values for the database connection.
Does anyone have an idea what could be wrong, or how i can dig further into what could be wrong?