how to clear cache in laravel on server code example

Example 1: laravel clear cache

php artisan cache:clear
php artisan route:clear
php artisan config:clear 
php artisan view:clear

Example 2: laravel artisan clear cache

//Updated Dec 2020
//laravel artisan clear cache 
php artisan view:clear 
php artisan cache:clear
php artisan route:clear
php artisan config:clear

Example 3: laravel artisan clear cache

//laravel artisan clear cache 
php artisan view:clear 
php artisan cache:clear
php artisan route:clear
php artisan config:clear

Example 4: artisan clear cache

php artisan cache:clear

Example 5: clear cache in laravel without artisan

Route::get('/clear-cache', function() {
     $exitCode = Artisan::call('cache:clear');
     return 'Application cache cleared';
 });

Example 6: clear cache in laravel without artisan

Route::get('/route-cache', function() {
     $exitCode = Artisan::call('route:cache');
     return 'Routes cache cleared';
 });

Tags:

Php Example