Debugging a page request in PHP, simple right? Either output to the page or command-line using something like var_dump, or use a step-through debugger to go through line-by-line. The advantage of the former is that it’s quick, and although the latter is more thorough it can be quite time-consuming.
However when you’re debugging an AJAX request, you can’t simply output as it’ll usually break the response that your JavaScript is expecting. Triggering AJAX events for step-by-step debugging can be tricky too. So what do you do?
Output log messages to Firebug!
$writer = new Zend_Log_Writer_Firebug(); $logger = new Zend_Log($writer); $logger->info('Started debugging');
Setup the logger (somewhere like the bootstrap) and enable the Net panel in Firebug. Then you can simply output log messages as usual, but when using this writer they’ll appear in the Firebug console as opposed to a file or database.