我现在有点困惑。我总是像其他树枝函数一样使用树枝转储函数,但现在它完全没有输出。没有错误/异常,什么都没有。
其他一切都工作正常,例如反式过滤器。
{{ dump('test') }} # prints nothing
{{ 'layout.booking.chooseArea'|trans }} # prints the translated message
目前该模板仅包含这些内容。
转储在父模板或 base.html.twig 中也不起作用。
同样,转储不打印任何内容:不是空字符串,不是 null,也不是屏幕上的单个像素。
有什么想法可能导致这种情况吗?
Symfony 版本:2.6.x-dev
update
{{ dump('test') }} # doesn't work (anymore?)
{% dump('test') %} # does (still) work
这是被删除了还是什么?为什么没有错误?顺便说一句...调试标志已设置。
在 Symfony 2.6 中,有一个新的 VarDumper 组件和 DebugBundle。这些覆盖了树枝的dump()
函数提供更多更好的转储输出。
但是,您必须在您的AppKernel
,否则它将忽略该呼叫。为此,您应该将其添加到app/AppKernel.php
:
// app/AppKernel.php
// ...
public function registerBundles()
{
// ...
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
// ...
}
return $bundles;
}
请注意,这个新的转储功能会将输出转储到 Web 开发工具栏中,以避免搞乱页面布局。
在 2.6.0 中,这个问题将通过回退到原生树枝来解决dump()
函数为什么 DebugBundle 没有注册。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)