Code snippets for symfony 1.x


Debug an object or variable (easy way)

This in the easiest way (I found) to debug an object (or variable).

In an action

$this->debugMessage(sprintf('<h1>object</h1><pre>%s</pre>', print_r(@$this->object, true)));

In a template

<?php use_helper('Debug') ?>
<?php echo debug_message(sprintf('<h1>object</h1><pre>%s</pre>', print_r(@$object, true))) ?>

Based on symfony book debug page.

by brikou on 2006-06-24, tagged debug  object 

Comments on this snippet

gravatar icon
#1 Loïc Vernet on 2007-12-20 at 12:08

Advanced version here :