Laravel php artisan config:cache not reflecting new environment changes
#59538
-
|
I deployed my Laravel app and ran: php artisan config:cacheEverything worked fine. But later, I updated For example, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
This is expected behavior: once you run So when you change Solution:
|
Beta Was this translation helpful? Give feedback.
This is expected behavior: once you run
php artisan config:cache, Laravel compiles all configuration files (including.envvalues) into a single cached file (bootstrap/cache/config.php). After that, Laravel no longer reads.envdirectly.So when you change
.env, those changes won’t apply until you clear and rebuild the cache.Solution:
Clear the config cache:
This deletes the cached config file.
Rebuild the cache:
This regenerates the cache with your updated
.envvalues.Best practices:
php artisan config:clearafter changing.envin production.