Just as I was about to run:
php artisan cache:clear
php artisan view:clear
php artisan route:clear
...for debugging purposes, I ended up running php artisan clear
instead. I got back the following output:
Compiled services and packages files removed!
What have I just done, and how do I undo it? My application still seems to work fine, but if things are broken, I'd rather roll things back now rather than get further down the line before I eventually realise that they are. If things aren't broken, I'd still like to know what I just did.
This question is not a duplicate of current questions because it specifically asks about the (undocumented) clear
alias.
Although:
php artisan clear
...isn't listed in artisan
's documentation at all (or at least not in php artisan list
), based on its output it seems to be an alias of:
php artisan clear-compiled
This seems to be confirmed by php artisan help clear-compiled
:
Description:
Remove the compiled class file
Usage:
clear-compiled
Although that help command doesn't really clear up much, like what exactly compiled class files are or what relation they have to any of the other clear commands, I'm guessing the command does something similar to:
php artisan view:clear
...which does the following according to its own help command:
Description:
Clear all compiled view files
Usage:
view:clear
Based on the above, I can only guess that running php artisan clear
is about as harmless as running php artisan view:clear
, in that both are designed to clear away compiled files that, when cleared, are simply recompiled again on the next build.
How exactly php artisan clear
differs from php artisan view:clear
and why it needs its own separate command and a much more memorable alias than any of the other clear commands is still... unclear.
To anyone else that arrived here because they find themselves constantly running some variation of the above commands for debugging and troubleshooting, I just learnt about the php artisan optimize:clear
command, which runs all of these commands at once:
php artisan view:clear
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan clear
and returns the following output:
Compiled views cleared!
Application cache cleared!
Route cache cleared!
Configuration cache cleared!
Compiled services and packages files removed!
Caches cleared successfully!