how to clean Laravel Bootstrap cache config file?

2020-05-26 06:12发布

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?

8条回答
叛逆
2楼-- · 2020-05-26 06:21

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

查看更多
够拽才男人
3楼-- · 2020-05-26 06:23

Use php artisan cache:clear to flush the application's cache.

查看更多
SAY GOODBYE
4楼-- · 2020-05-26 06:27

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 new version of your application you may have outdated entries in the cache which in turn will make the artisan command to crash i.e. cannot find some class that was cached but no longer exist. Therefore you either need to:

1) Clear cache before you deploy the application

php artisan cache:clear

2) Clear cache manually

rm -fr bootstrap/cache/*

Finally you want to run optimize command which will re-build your configuration cache, bootstrap file cache and route caches.

php artisan optimize
查看更多
孤傲高冷的网名
5楼-- · 2020-05-26 06:39

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.

查看更多
时光不老,我们不散
6楼-- · 2020-05-26 06:39

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();
查看更多
Animai°情兽
7楼-- · 2020-05-26 06:41
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

查看更多
登录 后发表回答