Friday, April 10th, 2009
FirePHP: Tying together Firebug and PHP

FirePHP solves the problem of AJAX debugging by sending debug information along with the response. To avoid breaking the response content, the debug information is placed into special HTTP response headers. This works for all types of requests, not just AJAX requests, which means you can even debug requests for images that are dynamically generated by a PHP script. You can use FirePHP in your development environment, or use it to track down bugs that only appear on your production site.
This is what Christoph Dorn has to say about FirePHP in his recent writeup.
He goes into detail on how you can setup the Firebug plugin, and how you use it from within PHP:
-
-
// use an ini file to turn it on and off
-
-
if ($settings['FirePHP'] == 'Enabled') {
-
FB::setEnabled(true);
-
} else {
-
FB::setEnabled(false);
-
}
-
-
// log away!
-
-
// selectively log
-
if (Debug::getOption('DisableCache')) {
-
// code to disable cache
-
FB::info('Cache has been disabled!');
-
} else {
-
// default code
-
}
-
Check out the article for more info.
In related news, Zend just stepped it up a notch with their new Zend Server that fits in nicely with the cloud.












There are also libraries for non-PHP languages, including server-side JS:
http://www.firephp.org/Wiki/
http://nlsmith.com/projects/console
It’s a great program. It would be nice to have Mozilla and other browser vendors adopt wildfire or a similar standard to allow this sort of thing everywhere.
YOU’RE ONLY FINDING OUT ABOUT THIS NOW? :O
Its uses are limited though – any AJAX application without a proper error metadata system (which can be used for debugging) isn’t very well coded.
I can see it’s use for some developers, but seems to me like using a Claw Hammer to remove a screw, a bit OTT. Errors should *never* be output with a response, even in the development phase – if you forget to hide them when you release you run the very real risk of exposing your code secrets and vulnerabilities.
I say use http://php.net/set_error_handler to update logs in a protected area you can view online, and throw yourself an email to boot (for future errors)