How to stop Laravel 5 from caching configurations?

Laravel 5

Laravel 5 Problem Overview


It is written in Laravel 5 documentation that php artisan config:cache stores all the app configuration into one single file which makes the application load faster.

I want to know two things:

The first thing is, how to force Laravel to stop caching my app configurations? For example, I want Laravel to read the name of my database and the password from the .env file or from the database.php configuration file, not from the cached data.

The second thing is, where does Laravel store this cached configuration file, so that I can delete it when needed? I know there is an Artisan command for that, which is php artisan config:clear, but I want to know where the file stored.

Laravel 5 Solutions


Solution 1 - Laravel 5

You can't stop the caching of config files since it doesn't happen automatically. The only thing you need to do, is not call config:cache.

The file itself can be found in bootstrap/cache/config.php.

Note that the location of the compiled config file has changed recently. Yours might also be in vendor/config.php or storage/framework/config.php. With a fresh install or if you run composer update the file should be in bootstrap/cache though.

Solution 2 - Laravel 5

As per the post here: https://github.com/laravel/framework/issues/2501

> "Change cache driver to array for the local environment."

For me this involves adding CACHE_DRIVER=array to my .env file. This is then picked up by my config/cache.php file which includes the line: 'default' => env('CACHE_DRIVER', 'file'),

Obviously you could change it directly in the config/cache.php but I'd prefer to use the .env file so I can disable it for development sites and enable for production.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionwessodesignerView Question on Stackoverflow
Solution 1 - Laravel 5lukasgeiterView Answer on Stackoverflow
Solution 2 - Laravel 5LexView Answer on Stackoverflow