如何在 TWIG 中使用转储? [英] How to use dump in TWIG?
本文介绍了如何在 TWIG 中使用转储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我简单地为模板(index.html.twig)添加:
I add for template (index.html.twig) simply:
{{ dump(product) }}
我有错误:
The function "dump" does not exist in AcmeStoreBundle:Default:index.html.twig at line 2
为什么这个功能没有开启,如何开启?
Why this function is not enable, and how can i enable this?
推荐答案
您需要 配置调试扩展:
# app/config/config.yml
services:
acme_hello.twig.extension.debug:
class: Twig_Extension_Debug
tags:
- { name: 'twig.extension' }
根据上面提到的链接,Twig 调试在运行 Twig 1.16+ 的 Symfony 2.5+ 中默认设置为工作,并且不需要自定义服务定义.有关详细信息,请参阅此答案.
Per the link mentioned above, Twig debugging is set to work by default in Symfony 2.5+ running Twig 1.16+, and the custom service definition is not necessary. See this answer for more details.
这篇关于如何在 TWIG 中使用转储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文