Too much data with var_dump in symfony2 doctrine2

I have about 40 entities and many bi-directional relationships. Whenever I use var_dump ($ user) or any entity, my browser loads too many arrays and variables, then it just crashes.

I want a problem.

Data is inserted in a fine. May I cause a problem in production.

+84
debugging php doctrine2
Aug 10 2018-12-12T00:
source share
9 answers

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

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

It works for individual Doctrine objects and collections and should prevent the browser from displaying the problems you have.

+194
Aug 11 2018-12-12T00:
source share

well formatted:

 echo '<pre>'; \Doctrine\Common\Util\Debug::dump($user, $recurciveLevelToDisplay); echo '</pre>'; 
+18
Jun 28 '13 at 8:25
source share

A simple and easy example.

 var_dump(serialize($Object)); 
+3
Nov 13 '15 at
source share

The problem is that in a bidirectional manner, both objects have a reference to each other, so when displaying entity1, var_dump will also have to print all the properties of entity2, which include entity1 itself, which gives you a loop.

+2
Jun 14 '13 at 8:42 on
source share

The get_object_vars () function improves visualization.

 echo "<pre>"; \Doctrine\Common\Util\Debug::dump(get_object_vars($user)); 
+1
Sep 17 '14 at 17:53
source share

Just use echo serialize ($ user);

+1
Jan 10 '15 at 12:31 on
source share

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

+1
Jan 28 '16 at 13:34
source share

Symfony <2.6

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

Symfony> 2.6

If you are using symfony 2.6 or more, I highly recommend that you use dump() . It shows a well-formed and colored output, and you can dynamically spend / hide lines. enter image description here

+1
Dec 6 '16 at 7:37
source share

With Symfony 2.6, now you can simply use dump ($ var) in your controller and {{dump (var)}} in the branch.

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

 $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); 
0
Apr 30 '15 at 2:17
source share



All Articles