laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.52k stars 11.02k forks source link

Bug in php proccessing env file #25098

Closed mustafa2033 closed 6 years ago

mustafa2033 commented 6 years ago

Description: When running multi laravel apps on the same host if one app thread is still proccessing any request the request to the other app takes its env vars from the first app, the first app connecting to remote db so its slow proccess but why the other app switching its env to the first one when he is proccessing, is this php issue?? Explenation needed.

Steps: Request to app 1 that is running slow proccess and befor the proccessing finished sending another request to app 2 will result both apps will have their env vars from app 1.

X-Coder264 commented 6 years ago

The reason why this happens can be found in this method https://github.com/vlucas/phpdotenv/blob/master/src/Loader.php#L363 :)

You must cache your config files (by running the command php artisan config:cache) so that LoadEnvironmentVariables bootstraper is never bootstrapped which means that the .env file will not be read anymore. That also means that you should not use the env() function anywhere outside of your config files as it will always return null then.