How to configure FirePHP with Magento to log response headers, dump objects to the browser console?
How to utilize FirePHP to reduce debugging time?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communitywe developed a small debugging suite for Magento which includes besides showing rewrite conflicts, a log file viewer, etc.. in the backend also integrations for FirePHP, ChromePHP and Firelogger.
You can find the extension here: https://github.com/firegento/firegento-debug
Once installed and activated in the system configuration, you can log your data for FirePHP like this:
Mage::helper('firegento/log')->firephp(WHAT_YOU_WANT_TO_LOG)
Since Magento comes with the Zend Framework bundled you can use Zend_Log_Writer_Firebug. One of the examples on ZF documentation shows how to use it
http://framework.zend.com/manual/1.12/en/zend.log.writers.html.
=> To not repeat yourself you can wrap this into your helper class
<?php
class Fooman_Common_Helper_Debug extends Mage_Core_Helper_Abstract {
/**
* send to Firebug
*
* @param $content
*/
public function sendToFirebug($content) {
$writer = new Zend_Log_Writer_Firebug();
$logger = new Zend_Log($writer);
$request = new Zend_Controller_Request_Http();
$response = new Zend_Controller_Response_Http();
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$channel->setRequest($request);
$channel->setResponse($response);
// Start output buffering
ob_start();
// Now you can make calls to the logger
$logger->log($content, Zend_Log::INFO);
// Flush log data to browser
$channel->flush();
$response->sendHeaders();
}
}
=> and then every time you want to send something to the firephp console use it
Mage::helper('foomancommon/debug')->sendToFirebug("TEST");
Mage::helper('foomancommon/debug')->sendToFirebug(Mage::app()->getRequest());
Mage::helper('foomancommon/debug')->sendToFirebug(Mage::app()->getResponse());
The actual response headers that are sent would be viewable on the net tab.