Ben*_*ird 20 caching laravel blade
我的一个观点中有一个例外.然而,laravel没有告诉我视图的名称,所以我可以找到并修复它app/storage/views/110a3ecc0aa5ab7e6f7f50ef35a67a8b,而不是没有意义.
如何禁用此视图缓存,以便laravel使用并引用实际文件?
Ant*_*iro 20
盒子外面?你不能.但是您可以扩展BladeCompiler类,覆盖方法resposible以检查视图是否已过期:
class MyBladeCompiler extends BladeCompiler {
public function isExpired($path)
{
if ( ! \Config::get('view.cache'))
{
return true;
}
return parent::isExpired($path);
}
}
Run Code Online (Sandbox Code Playgroud)
您需要使用自己的编译器替换IoC容器中的BladeCompiler实例:
$app = App::make('app'); // or just $app = app();
$app->bindShared('blade.compiler', function($app)
{
$cache = $app['path.storage'].'/views';
return new MyBladeCompiler($app['files'], $cache);
});
Run Code Online (Sandbox Code Playgroud)
然后你只需要在app/config/view.php文件中创建该密钥
<?php
return [
'cache' => false,
'paths' => [base_path().'/resources/views'],
'pagination' => 'pagination::slider-3',
];
Run Code Online (Sandbox Code Playgroud)
或者,就像我在这里:
return [
'cache' => in_array(App::environment(), ['production', 'staging']),
];
Run Code Online (Sandbox Code Playgroud)
Ber*_*ner 14
在 laravel > v9.7.0 中,您可以在里面添加config/view.php:
'cache' => App::environment('local') ? false : true
Run Code Online (Sandbox Code Playgroud)
这是 PR: https: //github.com/laravel/framework/pull/41859
this worked for me... added this to the .env file
CACHE_EXPIRE=-1
Run Code Online (Sandbox Code Playgroud)
小智 7
解
打开php.ini
opcache.revalidate_freq=0
opcache.fast_shutdown=0
Run Code Online (Sandbox Code Playgroud)
改变这个.重启apache.
| 归档时间: |
|
| 查看次数: |
51869 次 |
| 最近记录: |