Laravel Clear Cache Using Artisan Command

Websolutionstuff | May-18-2020 | Categories : Laravel

In this tutorial, I am giving information about laravel artisan command which can help you to clear your application's cache, route cache, clear your application's view, and clear your config cache as well.

So, let's see how to clear cache in laravel 6/7/8, how to clear route cache, how to clear cache in laravel, laravel 6 how to clear route, laravel 6/7/8 artisan command, laravel clear cache route, how to clear config cache in laravel, how to clear view in laravel.

We can run these all commands in the command-line interface (CLI) as well as we can create one function which has stored all these functions and run directly this function without opening your terminal.

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

So, let's start to see laravel clear cache using artisan command

Clear Config Cache 

This command is used to clear/delete config bootstrap/cache/config.php file of your application.

php artisan config:cache

 

 

Clear Route Cache

This command is used to clear the route cache of your application.

php artisan route:cache

 

Clear Cache Laravel Application

This command is used to clear your application cache :

php artisan cache:clear

 

 

Clear View Cache Laravel

 This command is used to clear the view of the cache of your application.

php artisan view:clear

 

Above all commands are used only in your local command window, As we don't have access to SSL on shared hosting servers. So, we can also clear the cache by typing the code in the route file. Go to your routes/web.php file and put the below code.

<?php

Route::get('/clear-cache', function() {
	 $exitCode = Artisan::call('config:cache');
     $exitCode = Artisan::call('cache:clear');
     $exitCode = Artisan::call('view:clear');
     $exitCode = Artisan::call('route:cache');
});

After adding the above code we can clear all cache, view, route, config in local environments as well as in live server also.

To run this route you need to open your browser and after add this route like below.

http://localhost:8000/clear-cache OR http://your_site_name/clear-cache

 


You might also like:

Recommended Post
Featured Post
Laravel 10 AJAX CRUD Operations Example
Laravel 10 AJAX CRUD Operation...

In this article, we will see the laravel 10 ajax crud operations example. Here, we will learn about ajax crud operation...

Read More

Feb-27-2023

How To Get Data Between Two Dates In Laravel 9
How To Get Data Between Two Da...

In this article, we will see how to get data between two dates in laravel 9. Here we will learn how to count d...

Read More

Dec-19-2022

How To Create Zip File In Laravel 7/8
How To Create Zip File In Lara...

In this tutorial I will give you example of how to create zip file in laravel 7/8. Some times client's have requirme...

Read More

Dec-17-2021

How To Get Children Element In jQuery
How To Get Children Element In...

In this article, we will see how to get the children of this selector in jquery. You can use the find() method...

Read More

Jul-13-2022