Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Too much data with var_dump in symfony2 doctrine2

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.

i want to whats the problem.

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

like image 980
Mirage Avatar asked Aug 10 '12 12:08

Mirage


People also ask

What does Var_dump mean?

Definition and Usage The var_dump() function dumps information about one or more variables. The information holds type and value of the variable(s).

Why Var_dump () is preferable over Print_r ()?

It's too simple. The var_dump() function displays structured information about variables/expressions including its type and value. Whereas The print_r() displays information about a variable in a way that's readable by humans. Example: Say we have got the following array and we want to display its contents.

What does Var_dump return?

@JMTyler var_export returns a parsable string—essentially PHP code—while var_dump provides a raw dump of the data. So, for example, if you call var_dump on an integer with the value of 1, it would print int(1) while var_export just prints out 1 .

What is the difference between Var_dump () and Print_r ()?

var_dump() displays values along with data types as output. print_r() displays only value as output. It does not have any return type. It will return a value that is in string format.


1 Answers

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

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

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

like image 175
mgiagnoni Avatar answered Oct 05 '22 17:10

mgiagnoni