58

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
  • only solution is to not use artisan Commented Mar 8, 2023 at 23:00

2 Answers 2

68

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.

Sign up to request clarification or add additional context in comments.

6 Comments

Work for me, it's hard coded in Laravel 5 , at [ vendor/config.php ]
If you did however call config:cache during local development, you can undo this by deleting the bootstrap/cache/config.php file. Otherwise, you might experience that calling getenv() will not return the desired values
We had this issue when we've added config:cache as post deployment hook in envoyer (for production server). Oddly enough, somehow it did not take all the values from the .env file.
Im using Laravel 5.6 and my config doesn't change even after rm bootstrap/cache/config.php.
I ended up doing $config =require base_path('config/services.php');. We've struggled with this a few times in the past. Only laravel can make something this simple problematic.
|
-1

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.

1 Comment

This is completely unrelated. The settings in config/cache.php relate to Laravel's cache feature as documented here, which is not used when caching the configuration itself. The configuration is only ever cached in the form of PHP code inside bootstrap/cache/config.php.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.