Clear Cache with Artisan Command (CLI) - Laravel 9

Kailash Singh

Clear Cache with Artisan Command (CLI) - Laravel 9

Published Feb 12,2023 by Kailash Singh

0 Comment     1346 Views    


In this tutorial, we are going to teach you, how to Clear Cache with Artisan Command (CLI).

 

Clear Route Cache in Laravel:

php artisan route:cache

 

Clear Application Cache in Laravel:

php artisan cache:clear

 

Clear Config Cache in Laravel:

php artisan config:cache

 

Clear View Cache in Laravel:

php artisan view:clear

 

Reoptimize Class:

php artisan optimize

 

Laravel clear cache without artisan:

Its not possible with shared hosting servers to access SSH there relying on artisan commands to clear, remove or delete cache in Laravel. However, there is one more trick in my book, and that is incorporating THE Artisan::call() method within the routes/web.php file with given below methods.

Example:

//Remove route cache
Route::get('/clear-route-cache', function() {
    $exitCode = Artisan::call('route:cache');
    return 'All routes cache has just been removed!';
});

//Remove config cache
Route::get('/clear-config-cache', function() {
    $exitCode = Artisan::call('config:cache');
    return 'Config cache has just been removed!';
}); 

//Remove application cache
Route::get('/clear-app-cache', function() {
    $exitCode = Artisan::call('cache:clear');
    return 'Application cache has just been removed!';
});

//Remove view cache
Route::get('/clear-view-cache', function() {
    $exitCode = Artisan::call('view:clear');
    return 'View cache has jut been removed!';
});

 


Comments ( 0 )


SEARCH POST HERE

Support Us

Subscribe My YouTube Channel

Join Our Telegram Channel & Support Eachother

CATEGORIES

INTERVIEW QUESTIONS

PROJECT SOURCE CODE






POPULAR POSTS