var_dump() in Firebug

In my previous post I talked about query profiling in Firebug with FirePHP. Today I will talk about another feature from the Zend Framework and FirePHP: logging.

Again, it’s very simple:

  • create a new Zend_Log
  • add the Zend_Log_Writer_Firebug to it
$log = new Zend_Log();
$log->addWriter(new Zend_Log_Writer_Firebug());
$log->debug($something);

This will behave like var_dump(), with these differences/improvements:

  • the output is displayed in Firebug
  • the HTML output doesn’t change
  • also for Ajax calls; no var_dump() info visible in the output from the Ajax call
  • the output has a nice layout

Remark: to use this, you need Firebug and FirePHP