Home / Snippets / How to Clear Config Cache in Laravel
How to Clear Config Cache in Laravel cover

How to Clear Config Cache in Laravel

644

2 years ago

0 comments

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

notion avatar

Ahabz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

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

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this