How to stop Laravel 5 from caching configurations?

2019-01-22 01:05发布

问题:

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.

回答1:

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.



标签: laravel-5