Pretty dump variable/object in Symfony 2.*?

最后都变了- 提交于 2019-12-07 06:09:11

问题


When developing stuff I need to output the state of some instance in order to inspect it.

While using CakePHP I always had a debug() function which does some kind of var_dump inside a <pre> html element, so the content is readable.

Is something similar in Symfony 2.x too?


回答1:


exit(\Doctrine\Common\Util\Debug::dump($someVar));



回答2:


use

\Doctrine\Common\Util\Debug::dump($user);




回答3:


As of today, one of the best ways to debug in Symfony that I know of is the Ladybug Bundle. Its output is similar to xdebug's, but it has some nice features, like a collapsible tree structure for arays or automatically linking to documentation pages (supporting standard PHP, Doctrine and Symfony).

You can find some great examples of its use on the README.




回答4:


Now there is a new function in Symfony - dump(), have a look at http://symfony.com/blog/new-in-symfony-2-6-vardumper-component



来源:https://stackoverflow.com/questions/15604565/pretty-dump-variable-object-in-symfony-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!