Laravel 8 Clear Cache Using Artisan Command
In this tutorial, We will discuss to you how to clear cache using artisan command in Laravel 8. sometimes we face an issue that any changes to our laravel application are not reflecting on the web interface. At that time we have a need to clear the cache for our laravel application.
There are many types of cache available in laravel like route cache, view cache, application cache, and config cache. so we can easily clear cache using the artisan command. let’s see the following clear cache.
Clear Laravel Application Cache
Here below command help to Clear Laravel Application Cache.
1 | php artisan cache:clear |
If you want to Clear Laravel Application Cache without php artisan command so you can below code using to Clear Laravel Application Cache.
1 2 3 4 | Route::get('/clear-application-cache', function() { Artisan::call('cache:clear'); return 'Application cache cleared'; }); |
Clear Route Cache
Here below command help to Clear Route Cache.
1 | php artisan route:cache |
If you want to Clear Route Cache without php artisan command so you can below code using to Clear Route Cache.
1 2 3 4 | Route::get('/clear-route-cache', function() { Artisan::call('route:cache'); return 'Routes cache cleared'; }); |
Clear Config Cache
Here below command help to Clear Config Cache.
1 | php artisan config:cache |
If you want to Clear Config Cache without php artisan command so you can below code using to Clear Config Cache.
1 2 3 4 | Route::get('/clear-config-cache', function() { Artisan::call('config:clear'); return 'Config cache cleared'; }); |
Clear View Cache
Here below command help to Clear View Cache.
1 | php artisan view:cache |
If you want to Clear View Cache without php artisan command so you can below code using to Clear View Cache.
1 2 3 4 | Route::get('/clear-view-cache', function() { Artisan::call('view:clear'); return 'View cache cleared'; }); |
Read Also
Laravel 8 S3 File Upload Tutorial With Example
Laravel 8 Newsletter Tutorial With Example
Laravel 8 Rest API CRUD Example With Passport Auth