Categories


Dumping doctrine entities without print_r

I’ve run into a problem with a personal project I’ve been working on, whereby my normal debugging process is to ensure I’m getting the correct data from the database using php’s print_r function. Recently this has been causing Apache to hang on my laptop, due to the massive quantity of memory PHP uses when trying to dump doctrine entities. After a bit of searching through the Doctrine documentation, I found a Doctrine dump function that will properly dump out a Doctrine object without the massive recursion / memory requirements.

So, without further adieu:

print "\<pre\>";
print_r($entity);
print "\</pre\>";

Becomes:

print "\<pre\>";
\Doctrine\Common\Util\Debug::dump($entity);
print "\</pre\>";

1 Comments Add Yours ↓

  1. Ulf #
    1

    Perfect. Thank you!



Your Comment