Laravel 5 loading wrong .env file

Posted 3 years ago by KSHIntern1

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?

Please sign in or create an account to participate in this conversation.