Slim + Twig - 如何在开发过程中关闭 Twig 缓存?
Slim + Twig - how to turn off Twig cache during development?
这是我将它注入到 Slim 容器中的 twig 视图:
// 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 始终从缓存中读取模板。在开发期间,有什么方法可以关闭缓存?
将 "cache" 更改为 false。
像这样
$twig = new Twig_Environment($loader, array(
'cache' => false,
));
这是我将它注入到 Slim 容器中的 twig 视图:
// 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 始终从缓存中读取模板。在开发期间,有什么方法可以关闭缓存?
将 "cache" 更改为 false。 像这样
$twig = new Twig_Environment($loader, array(
'cache' => false,
));