本文介绍了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:

无法启动会话,因为标头已由vendorsymfonyvar-dumperDumperAbstractDumper.php"在第 181 行发送.

Failed to start the session because headers have already been sent by "vendorsymfonyvar-dumperDumperAbstractDumper.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 也是正确的,要在 twig 文件中输出转储,请执行

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

{{ dump(variable) }}

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

08-12 15:07