Slim + Twig - 如何在开发过程中关闭Twig缓存?

3

这是一个视图,使用twig格式,并且我将其注入到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 会始终从缓存中读取模板。我能否在开发期间关闭缓存?

1个回答

10

将 "cache" 更改为 false。像这样

$twig = new Twig_Environment($loader, array(
    'cache' => false,
));

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接