Andrew Havens Ruby Developer

Setting up logging with Firebug and FirePHP in Zend Framework 1.7.5

18 November 2010

Question: How do I set up logging with FirePHP in Zend Framework?


  • Step 1: Make sure you have Zend Framework 1.6+
  • Step 2: Install both Firebug and FirePHP extensions for Firefox.
  • Step 3: Make sure you have Console and Net enabled.
  • Step 4: Set up Zend Log in your bootstrap file:

$writer = new ZendLogWriterFirebug(); $logger = new ZendLog($writer);

You can now send a log message to Firebug with the following code (in your bootstrap file):

$logger->log('Hello World!', Zend_Log::DEBUG);

If you wanted to use the logger outside of your bootstrap file, you can set $logger in the session:

Zend_Registry::set('logger', $logger);

$logger = ZendRegistry::get('logger'); $logger->log('This is my log message', ZendLog::INFO);

However, when I want to debug, I don’t want a bunch of lines or characters when I just want to output something to the logger. So I prefer to make a function in my bootstrap file that can be used throughout my application:

$writer = new ZendLogWriterFirebug(); $logger = new ZendLog($writer); Zend_Registry::set('logger', $logger);

function debug($message) { $logger = Zend_Registry::get('logger'); $logger->debug($message); }

That way, in my I can use by simply calling: