dimanche 7 mai 2017

Laravel 5.4 - How to clear laravel cache from code?

With this method can you easily clear the cache programatically.

first you need to go to ~/.env in your project root.

then add the following line anywhere in the file
... DISABLE_CACHE=true ...

Now, in ~/app/Http/Controller.php add

public function __construct(){
    if(env("DISABLE_CACHE")) {
        \Illuminate\Support\Facades\Artisan::call("view:clear");
        \Illuminate\Support\Facades\Artisan::call("cache:clear");
    }
}

hope this helps you guys to go on developing further ;)

happy developing!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire