Laravel 5 how to clear cache using composer.json

2019-03-06 09:25发布

I am new to Laravel. I am trying to clear view cache, and I need to clear view cache without composer.

Is possible to clear cache using composer.json autoload?

I have already tried the code below, but it was not working.

routes.php

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

Also, how should I use...

Cache::flush();

...in my code controller.

3条回答
Evening l夕情丶
2楼-- · 2019-03-06 09:57

May be something like this?

public function index()
    {
        $value = Cache::flush();

        return view('your.view')->with($value);
    }
查看更多
我只想做你的唯一
3楼-- · 2019-03-06 10:10

Why not try clear browser cache ?

I think the view cache saved by browser.

查看更多
The star\"
4楼-- · 2019-03-06 10:11

With a Filemanager or a Simple PHP Code Delete the compiled views inside of storage\framework\views

Example:

Route::get('/view-clear', function() {
    $directory=storage_path('framework/views');  
    $files=File::allFiles($directory);
    File::delete($files);
    return '<h1>View cache cleared</h1>';
});
查看更多
登录 后发表回答