Slim + Twig - how to turn off Twig cache during development?

ぃ、小莉子 提交于 2020-01-04 03:44:07

问题


This is the view which is twig that I inject it in the container in 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;
};

With this setting, Twig always read the template from the cache. Is there any way I can turn off the cache during the development?


回答1:


change "cache" to false. Like this

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


来源:https://stackoverflow.com/questions/42584433/slim-twig-how-to-turn-off-twig-cache-during-development

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!