'how to clean Laravel Bootstrap cache config file?
I developed laravel app locally and uploaded in shared hosting.
While hosting I changed the database name and username of mysql in the .env and the config/database files.
But in remote its still using the old db name and user which is found in the bootstrap/cache/config file.
So how to clean the bootstrap/cache/config.php file?
Solution 1:[1]
If you are trying to clear configuration cache, which it sounds like you are. You need to run:
php artisan config:clear
At some point, you probably ran php artisan config:cache which generated a cached version of your config file, and this file is not cleared with php artisan cache:clear
Solution 2:[2]
I tried all the above options but nothing works.
I manually removed from bootstrap/cache/config.php. And it works. This is the Ultimate solution.
Solution 3:[3]
I just stumbled into this while building automated deployment in AWS. The problem with Laravel is that artisan commands also use the cache. Now if you deploy the new version of your application you may have outdated entries in the cache which in turn will make the artisan command crash i.e. cannot find some class that was cached but no longer exist. Therefore you either need to:
- Clear cache before you deploy the application
php artisan cache:clear
- Clear cache manually
rm -rf bootstrap/cache/*.php
Finally you want to run optimize command which will re-build your configuration cache, bootstrap file cache and route caches.
php artisan optimize
Solution 4:[4]
php artisan config:clear
Or you can just manually delete bootstrap/config.php, which is what artisan does after all.
See: vendor\laravel\framework\src\Illuminate\Foundation\Console\ConfigClearCommand.php
Solution 5:[5]
Here is the Tip,
Flushing Application cache
- Use
php artisan cache:clearto flush the application cache orphp artisan cache:forgetto discard specific cache. - You can use
php artisan config:clearto clear cached configuration of application.
- Use
Removing Blade Templates cache
You can use
php artisan view:clearto clear all compiled views.Application Bootstrap cache
If you want to clear the application bootstraper cache,
php artisan optimize:clearwill help you.Route Cache
There also a command to clear the route cache as
php artisan route:clear.Events and Listeners cache
For events and listeners cache you can use
php artisan event:clear
if you still stuck in finding helpful commands, you can run php artisan list and it will list out every command with its description. look for a specific thing you want to perform. if you need migration-related command, you can look in migration.
Solution 6:[6]
The solution for me was to remove the files in the bootstrap/cache/ directory and then delete the vendor folder. Re-run composer install and then composer dump-autoload and the above campaigns should run fine. Deleting the vendor folder and re-running composer install was the missing link for me
Solution 7:[7]
You can use:
Laravel 4 : php artisan cache:clear
also for laravel 5(not tested),
Illuminate\Cache\FileStore has the function flush
Cache::flush();
also,
use Doctrine\Common\Cache\CacheProvider as DoctrineCache;
DoctrineCache::flushAll();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rahul |
| Solution 2 | |
| Solution 3 | Community |
| Solution 4 | Lucas Bustamante |
| Solution 5 | Kiran Maniya |
| Solution 6 | Connor Leech |
| Solution 7 | Ajit Kumar Singh |
