在symfony2学说中有太多的var_dump数据。

时间:2021-11-08 01:03:42

I have around 40 entities and many bidirectional relationships. Whenever i use var_dump($user) or any entity my browser gets loaded with too much data of arrays and variables then it just crashed.

我有大约40个实体和许多双向关系。每当我使用var_dump($user)或任何我的浏览器加载了太多数组和变量数据的实体时,它就会崩溃。

i want to whats the problem.

我想知道是什么问题。

The data is being inserted fine. Can i cause issue in production.

数据被插入得很好。我可以在生产中引起问题吗?

9 个解决方案

#1


200  

Replace var_dump() with the debug method dump() provided by Doctrine Common.

用Doctrine Common提供的debug方法dump()替换var_dump()。

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

It works for single objects and Doctrine collections and should prevent browser displaying issues you are having.

它适用于单个对象和原则集合,应该可以防止浏览器显示您所遇到的问题。

#2


19  

well formatted :

格式:

echo '<pre>';
\Doctrine\Common\Util\Debug::dump($user, $recurciveLevelToDisplay);
echo '</pre>';

#3


3  

Simple and easy example.

简单和容易的例子。

var_dump(serialize($Object));

#4


2  

The problem is that in a bidirectional relationship both entities have a link to each other, so while displaying entity1 var_dump will also have to print all properties of entity2, which include entity1 itself giving you a loop.

问题是,在双向关系中,两个实体之间都有一个链接,因此在显示entity1 var_dump时,还必须打印entity2的所有属性,其中包括entity1本身,给您一个循环。

#5


2  

With Symfony 2.6 you can now just use dump($var) in your controller and {{ dump(var) }} in twig.

使用Symfony 2.6,您现在可以在控制器中使用dump($var),在twig中使用{{dump(var)}。

Make sure to add this to your AppKernal.php file, in the array('dev', 'test') section.

一定要把这个添加到你的AppKernal。php文件,在数组('dev', 'test')部分。

$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();

#6


1  

The get_object_vars() improve the visualization too.

get_object_vars()也改进了可视化。

echo "<pre>";
\Doctrine\Common\Util\Debug::dump(get_object_vars($user));

#7


1  

Just use echo serialize($user);

只使用回声序列化($ user);

#8


1  

use dump($user) and you can see perfect result in Symfony Profiler! good luck

使用dump($user),您可以在Symfony Profiler中看到完美的结果!祝你好运

#9


1  

Symfony < 2.6

Symfony < 2.6

You can use \Doctrine\Common\Util\Debug::dump($variable, $depth); it displays doctrine output without the proxy information.

您可以使用\Doctrine\ Util\Debug::dump($variable, $depth);它显示没有代理信息的学说输出。

Symfony > 2.6

Symfony > 2.6

If you are using symfony 2.6 or more, I strongly advice you to use dump(). It shows a well formated and colored output, and you can dynamically expend/hide rows. 在symfony2学说中有太多的var_dump数据。

如果您正在使用symfony 2.6或更多,我强烈建议您使用dump()。它显示了一个格式良好的彩色输出,您可以动态扩展/隐藏行。

#1


200  

Replace var_dump() with the debug method dump() provided by Doctrine Common.

用Doctrine Common提供的debug方法dump()替换var_dump()。

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

It works for single objects and Doctrine collections and should prevent browser displaying issues you are having.

它适用于单个对象和原则集合,应该可以防止浏览器显示您所遇到的问题。

#2


19  

well formatted :

格式:

echo '<pre>';
\Doctrine\Common\Util\Debug::dump($user, $recurciveLevelToDisplay);
echo '</pre>';

#3


3  

Simple and easy example.

简单和容易的例子。

var_dump(serialize($Object));

#4


2  

The problem is that in a bidirectional relationship both entities have a link to each other, so while displaying entity1 var_dump will also have to print all properties of entity2, which include entity1 itself giving you a loop.

问题是,在双向关系中,两个实体之间都有一个链接,因此在显示entity1 var_dump时,还必须打印entity2的所有属性,其中包括entity1本身,给您一个循环。

#5


2  

With Symfony 2.6 you can now just use dump($var) in your controller and {{ dump(var) }} in twig.

使用Symfony 2.6,您现在可以在控制器中使用dump($var),在twig中使用{{dump(var)}。

Make sure to add this to your AppKernal.php file, in the array('dev', 'test') section.

一定要把这个添加到你的AppKernal。php文件,在数组('dev', 'test')部分。

$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();

#6


1  

The get_object_vars() improve the visualization too.

get_object_vars()也改进了可视化。

echo "<pre>";
\Doctrine\Common\Util\Debug::dump(get_object_vars($user));

#7


1  

Just use echo serialize($user);

只使用回声序列化($ user);

#8


1  

use dump($user) and you can see perfect result in Symfony Profiler! good luck

使用dump($user),您可以在Symfony Profiler中看到完美的结果!祝你好运

#9


1  

Symfony < 2.6

Symfony < 2.6

You can use \Doctrine\Common\Util\Debug::dump($variable, $depth); it displays doctrine output without the proxy information.

您可以使用\Doctrine\ Util\Debug::dump($variable, $depth);它显示没有代理信息的学说输出。

Symfony > 2.6

Symfony > 2.6

If you are using symfony 2.6 or more, I strongly advice you to use dump(). It shows a well formated and colored output, and you can dynamically expend/hide rows. 在symfony2学说中有太多的var_dump数据。

如果您正在使用symfony 2.6或更多,我强烈建议您使用dump()。它显示了一个格式良好的彩色输出,您可以动态扩展/隐藏行。