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

lau*_*kok 3 php caching slim 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;
};
Run Code Online (Sandbox Code Playgroud)

使用此设置,Twig始终从缓存中读取模板.有什么办法可以在开发过程中关闭缓存吗?

Dan*_*sta 8

将"缓存"更改为false.像这样

$twig = new Twig_Environment($loader, array(
    'cache' => false,
));
Run Code Online (Sandbox Code Playgroud)