php Laravel 5 清除视图缓存
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29152102/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5 Clear Views Cache
提问by basagabi
I notice that Laravel cache views are stored in ~/storage/framework/views.
Over time, they get to eat up my space. How do I delete them? Is there any command that could? I tried php artisan cache:clear,
but it is not clearing the views cache. With that, I have to manually delete the files in the said folder.
我注意到 Laravel 缓存视图存储在~/storage/framework/views.
随着时间的推移,它们会占用我的空间。如何删除它们?有什么命令可以吗?我试过了,php artisan cache:clear,
但它没有清除视图缓存。有了这个,我必须手动删除所述文件夹中的文件。
Also, how do I disable the views caching?
另外,如何禁用视图缓存?
回答by DilipGurung
There is now a php artisan view:clear
command for this task since Laravel 5.1
php artisan view:clear
从 Laravel 5.1 开始,现在有此任务的命令
回答by Jake Pucan
To get all the artisan command, type...
要获取所有工匠命令,请键入...
php artisan
If you want to clear view cache, just use:
如果要清除视图缓存,只需使用:
php artisan view:clear
If you don't know how to use specific artisan command, just add "help" (see below)
如果您不知道如何使用特定的 artisan 命令,只需添加“帮助”(见下文)
php artisan help view:clear
回答by Mosam Prajapati
please try this below command :
请尝试以下命令:
sudo php artisan cache:clear
sudo php artisan view:clear
sudo php artisan config:cache
回答by ArjanSchouten
Right now there is no view:clear command. For laravel 4 this can probably help you: https://gist.github.com/cjonstrup/8228165
现在没有 view:clear 命令。对于laravel 4,这可能可以帮助您:https://gist.github.com/cjonstrup/8228165
Disabling caching can be done by skipping blade. View caching is done because blade compiling each time is a waste of time.
可以通过跳过刀片来禁用缓存。完成视图缓存是因为刀片每次编译都是浪费时间。
回答by Adam
To answer your additional question how disable views caching:
要回答您的其他问题如何禁用视图缓存:
You can do this by automatically delete the files in the folder for each request with the command php artisan view:clear
mentioned by DilipGurung. Here is an example Middleware class from https://stackoverflow.com/a/38598434/2311074
您可以php artisan view:clear
通过使用 DilipGurung 提到的命令为每个请求自动删除文件夹中的文件来完成此操作。这是来自https://stackoverflow.com/a/38598434/2311074的示例中间件类
<?php
namespace App\Http\Middleware;
use Artisan;
use Closure;
class ClearViewCache
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (env('APP_DEBUG') || env('APP_ENV') === 'local')
Artisan::call('view:clear');
return $next($request);
}
}
However you may note that Larevel will recompile the files in the /app/storage/views folder whenever the time on the views files is earlier than the time on the PHP blade files for the layout. THus, I cannot really think of a scenario where this would be necessary to do.
但是,您可能会注意到,只要视图文件的时间早于布局的 PHP 刀片文件的时间,Larevel 就会重新编译 /app/storage/views 文件夹中的文件。因此,我真的想不出有必要这样做的场景。
回答by Uddyan Semwal
use Below command in terminal
在终端中使用下面的命令
php artisan cache:clear
php artisan route:cache
php artisan config:cache
php artisan view:clear
回答by Hemant Kumar
Clear Cache in Laravel (Terminal)
清除 Laravel 中的缓存(终端)
Clear Application Cache
清除应用程序缓存
php artisan cache:clear
Clear route cache
清除路由缓存
php artisan route:clear
Clear config cache
清除配置缓存
php artisan config:clear
Clear compiled view files
清除编译的视图文件
php artisan view:clear
Clear Cache in Browser Most of the shared hosting providers don't provide SSH access to the systems. In that case, you can clear Laravel cache by calling URL in the browser. You can simply place the below code in your routes/web.php.
清除浏览器中的缓存 大多数共享主机提供商不提供对系统的 SSH 访问。在这种情况下,您可以通过在浏览器中调用 URL 来清除 Laravel 缓存。您可以简单地将以下代码放在您的 routes/web.php 中。
Route::get('/clear-cache', function() {
Artisan::call('cache:clear');
return "Cache is cleared";
});
Here is the resource link https://tecadmin.net/clear-cache-laravel-5/
回答by lzoesch
Here is a helper that I wrote to solve this issue for my projects. It makes it super simple and easy to be able to clear everything out quickly and with a single command.
这是我为解决项目问题而编写的帮助程序。它使能够使用单个命令快速清除所有内容变得非常简单和容易。