How reload Twig cache in Symfony 2

后端 未结 8 969
伪装坚强ぢ
伪装坚强ぢ 2020-12-13 17:51

I have a application which is developed in PHP using the Symfony 2 framework. I have changed a HTML file, but the change is not reflecting when I refresh the page.

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 18:05

    When creating a new Twig_Environment instance, you can pass an array of options as the constructor second argument. One of them is auto_reload. When developing with Twig, it's useful to recompile the template whenever the source code changes. If you don't provide a value for the auto_reload option, it will be determined automatically based on the debug value.

    Set auto_reload to be true:

    $twig = new Twig_Environment($loader, array('auto_reload' => true));
    

    Twig's documentation for developers: http://twig.sensiolabs.org/doc/api.html#environment-options

提交回复
热议问题