how to make changes in .env file without reloading server
I am using a form from front end to change my .env file variable values, after changing the values, changes are being saved in my env file, but its not reflecting on my laravel application, after restarting my server its reflecting on my website, but i cant do this if its in live server, I tried PHP artisan config:clear and PHP artisan cache:clear but none of its working.
Can anyone please tell me how to do this without restarting server.
I am trying to change these values in .env HTTP_HOST=http:// SFTP_HOST=10.10.10.64
The .env file is read during bootstrapping on each request (see here and here).
So a change to your .env file should be accounted for as early as during the next request, concerning web requests. You only have to restart your long-running processes like queue workers and such, wich you can do one-by-one.
If a change to your .env is not reflected on the next request, it has to be some caching issue, since the code I linked to clearly shows that it should be.
EDIT: In this thread on laracasts someone had a similar problem and solved it by deleting the vendor folder and doing composer install "to make sure nothing was broke in my autoloading".
And just to add to @christophharms reply, you should use env variables though the config files, so in case you do that already you just need to clear the config cache in case you cached it.. That can be done using
php artisan config:clear
This should be done in case you introduced a new variable, not when changing an existing one.
nakov its not working, i am calling env variables form config after editing env variable values from frontend, variables got changed in env but not reflecting in app.php file, please tell me how to do it
i kept this code in my app.php file to read those values from env, and in my controller i am retriving as shown below
$http_host = Config::get('app.HTTP_HOST');
$sftp_host = Config::get('app.SFTP_HOST');
after doing changes in env file, its changing in .env file bit not reflecting in app.php
It might be a permission problem so that the config:clear won't clear your cached file. You can try to find the cached file in bootstrap/cache/config.php and remove that one manually if that's the case.