Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reload .env constants in Laravel 5.2

I just changed a constant inside my .env file. The new value is shown up correctly with php-cli (via tinker), but not in my web app (php-fpm).

So far I've tried everything as suggested:

sudo service nginx restart
sudo service php7.0-fpm restart
sudo service php7.0-fpm reload

.

php artisan config:cache

This will generate a cache config file in bootstrap/cache/config.php

php artisan config:clear

This will remove cache config file in bootstrap/cache/config.php

php artisan cache:clear

What exactly does does ? What type of cache does it clear?

php artisan clear-compiled

This clear compile classes

composer dump-autoload

This will generate/update composer autoload file.

I have some .env variables that are not part of any config file. So it is useless for me to run any of the artisan commands.

None of the above php artisan commands don't deal directly with $_ENV.

Seems that $_ENV is stored somewhere in the server and laravel cannot update it once properties are populated.

The only solution I've found is restarting the server.

I'm running a Laravel Forge instance.

like image 441
John Smith Avatar asked Jun 16 '16 03:06

John Smith


1 Answers

If it is cached and you need to reload it you can simply use:

php artisan config:clear

This will pull in any changes that you have since made.

like image 100
James Avatar answered Dec 19 '22 00:12

James