本文介绍了Symfony 4:Var-dumper无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用symfony 4中var-dumper捆绑包中的精彩转储函数,由于某种原因,我收到以下错误:

I tried to use the wonderful dump function from the var-dumper bundle in symfony 4 and for some reason I get the following error:

由于标题已经由"vendor \ symfony \ var-dumper \ Dumper \ AbstractDumper.php"在第181行发送,因此无法启动会话.

Failed to start the session because headers have already been sent by "vendor\symfony\var-dumper\Dumper\AbstractDumper.php" at line 181.

另外,当我尝试在树枝模板中使用{%dump foo%}标签时,我得到一个错误:

Additionally, when I try to use the {% dump foo %} tag in a twig template I get an error:

未知的转储"标签.

有人可以帮助我吗?

推荐答案

在本课程的评论中提到了一个名叫Simon Waldburger的人,他说安装调试"可以解决问题(对我来说已经解决了).该说明在下一堂课中.

A guy named Simon Waldburger mentioned in the lesson's comments that installing "debug" fixed the issue (it fixed it for me). The instruction was in the next lesson.

composer require debug --dev

iiirxs也是正确的,要在树枝文件中输出转储,请执行

iiirxs is also correct, to output dump in twig file, do

{{ dump(variable) }}

这篇关于Symfony 4:Var-dumper无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 15:07