Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sstringer's avatar

Is there one artisan command that clears all caches?

Is there a single command that clears all caches including views and app caches?

Currently, I'm having to type in...

php artisan view:clear
php artisan cache:clear

Yes, I could write a script, etc. I'm just wondering if there's something already built into artisan that does this.

Thanks, Steve

0 likes
12 replies
hristodinev's avatar

Hi Steve, I think that the built one is php artisan cache:clear

pmall's avatar

Technically those are precompiled views, not cached views.

sstringer's avatar

Here's the "why:" my IDE can't ignore specific folders, so it searches through cached files. I find it speeds things up to blow away all caches before executing a site-wide search, so I'm looking for an efficient way to delete these files. Laravel comments tend to stuff caches all over the place, but particularly in the storage folder. I'm just wondering if Artisan is smart enough to be able to do its own cleanup, of if I'm stuck with the manual option.

sstringer's avatar

@hristodinev - Thanks. cache:clear does blow away the main site cache, but doesn't touch anything else. views:clear does clear away @pmall's precompiled views, but doesn't touch the cache. Just looking for one command to rule them all. Thanks, though.

pmall's avatar

You may also change your IDE for a better one :-)

2 likes
sustained's avatar

One solution is to add an entry to your package.json?

{
    ...
    "scripts": {
        ....
        "clear-cache": "php artisan cache::clear && php artisan config::clear && php artisan route::clear && php artisan view:clear"
    }
}

Then run npm run clear-cache?

1 like
plebot's avatar

A little bit late to the battle, but I guess php artisan optimize:clear is the right answer regarding the result of the command:

Compiled views cleared!
Application cache cleared!
Route cache cleared!
Configuration cache cleared!
Compiled services and packages files removed!
Caches cleared successfully!
10 likes
azimidev's avatar
php artisan route:clear && php artisan view:clear && php artisan config:clear && php artisan cache:clear && php artisan clear-compiled
2 likes
Marmot's avatar

@plebot That's whats I needed! My custom classes were not being applied until I did this. I forgot there was a view cache

Sinnbeck's avatar

@arif98741 Why clear the same caches more that once?

optimize:clear runs the following

        $this->call('view:clear');
        $this->call('cache:clear');
        $this->call('route:clear');
        $this->call('config:clear');
        $this->call('clear-compiled');
4 likes

Please or to participate in this conversation.