这是我在Slim中将它注入容器的视图:
// Views and Templates
// https://www.slimframework.com/docs/features/templates.html
$container['view'] = function ($container) {
$settings = $container->get('settings');
$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment($loader, array(
'cache' => 'cache',
));
// Add twig extension.
$twig->addExtension(new \Twig_Extensions_Extension_Array());
return $twig;
};
使用此设置,Twig始终从缓存中读取模板。我有什么方法可以在开发期间关闭缓存 ?
答案 0 :(得分:7)
将“缓存”更改为false。 喜欢这个
$twig = new Twig_Environment($loader, array(
'cache' => false,
));