Thursday, December 26, 2024
Google search engine
HomeLanguagesLaravel Delete Cache Files Manually | Without Artisan Command

Laravel Delete Cache Files Manually | Without Artisan Command

Laravel deletes cache files manually. In this tutorial, you will learn how to delete cache files manually in Laravel apps with and without using artisan commands.

There are 3 methods available to clear the cache in Laravel app. The cache of the app can be cleared using the command line. And in the other way the artisan can be executed by creating a route. lastly, the third method is to clear the cache manually.

How to Clear Cache in Laravel Apps with and without using Artisan Command

In this tutorial, you will know 3 ways by which you can clear the cache of the Laravel app. which are given below:

  • Solution 1 – Laravel Clear route, app, config, and view cache using Artisan Command
  • Solution 2 – Laravel Cache Clear using without Artisan Command
  • Solution 3 – Laravel Delete Cache Files Manually

Solution 1 – Laravel Clear route, app, config, and view cache using Artisan Command

Let’s use the different types of commands to delete or clear route, app, config , view cache in Laravel 10, 9,8,7,6 apps:

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

Solution 2 – Laravel Cache Clear using without Artisan Command

If you do not access SSH on shared hosting servers, then we can also clear the cache by typing the code in the route file. Go to your web.php file and add following code for clear the cache of your application :

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

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

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

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

Solution 3 – Laravel Delete Cache Files Manually

If the cache is not cleared yet. Then go to the bootstrap/cache directory. And delete all files and sub-directories inside the bootstrap/cache directory.

Or, you can execute the following on the terminal instead of manually deleting the file:

cd bootstrap/cache/
rm -rf *.php

Recommended Laravel Posts

Recommended:-Laravel Try Catch
RELATED ARTICLES

Most Popular

Recent Comments