【问题标题】:Slim + Twig - how to turn off Twig cache during development?Slim + Twig - 如何在开发过程中关闭 Twig 缓存?
【发布时间】:2017-03-04 00:55:30
【问题描述】:

这是我在 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 总是从缓存中读取模板。 在开发过程中有什么办法可以关闭缓存?

【问题讨论】:

    标签: php caching twig slim


    【解决方案1】:

    将“缓存”更改为 false。 像这样

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-10
      • 2013-09-23
      • 1970-01-01
      • 2016-04-28
      • 2017-03-05
      相关资源
      最近更新 更多