Posts Learn Components Snippets Categories Tags Tools About
/

How to Clear Config Cache in Laravel

Learn how to clear all config cache in Laravel using the artisan command and programmatically the easy way

Created on Oct 26, 2021

626 views

In this snippet, you will learn how to clear all of the config caches in Laravel by using the artisan command as well as programmatically calling it from the back-end code.

Using Artisan Command


To clear the config using the artisan command, you can simply run "config:clear" from your terminal/command line.
php artisan config:clear
This command will clear all the cached configuration of a file that's inside the "config" directory.

Clear Config Cache In Laravel Programmatically


To clear the config cache programmatically you can make use of that Artisan facade. For the code example below you can define a new route called "/clear-config-cache" and this will clear all the configurations when the URL path is accessed.
<?php

Route::get('/clear-config-cache', function () {
    Artisan::call('config:clear');
});

Other Clear Caching Reads

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

Load comments for How to Clear Config Cache in Laravel

)