FirePHP - The Firebug Extension for PHP

If you have been doing any Ajax development using PHP on the server side you are probably already using Firebug to find JavaScript errors. Wouldn't it be nice if you could also capture the server side PHP in the Firebug? Well, FirePHP makes it possible to do just that.

FirePHP acts as a logger and below is a code sample of how you would write to the log.

<?php

require('fb.php')

/* NOTE: You must have Output Buffering enabled via
         ob_start() or output_buffering ini directive. */

fb('Hello World'); /* Defaults to FB_LOG */

fb('Log message'  ,FB_LOG);
fb('Info message' ,FB_INFO);
fb('Warn message' ,FB_WARN);
fb('Error message',FB_ERROR);

fb('Message with label','Label',FB_LOG);

fb(array('key1'=>'val1',
         'key2'=>array(array('v1','v2'),'v3')),
   'TestArray',FB_LOG);

function test($Arg1) {
  throw new Exception('Test Exception');
}
try {
  test(array('Hello'=>'World'));
} catch(Exception $e) {
  /* Log exception including stack trace & variables */
  fb($e);
}

/* Will show only in "Server" tab for the request */
fb(apache_request_headers(),'RequestHeaders',FB_DUMP);

?> 

The key to using FirePHP is the use of the fb function which is available once you reference the fb.php file. In the function you pass in whatever you want to display and you can pass in variables that allow Firebug to capture the message as warnings, errors or logs. If you just want to log some information you would pass in FB_LOG or you can pass in FB_INFO for Firebug to display a message as info. If you pass in FB_WARN Firebug will treat it as a warning or if you pass in FB_ERROR it will treat it as an error.

You can read more about FirePHP and download the extension here.

I know I'm going to start really using this as it will help with development of many of the applications that we are working on for our Ajaxonomy Labs section. If you use FirePHP, I would love to hear your thoughts about it.





Digg!Reddit!Del.icio.us!Facebook!Slashdot!Netscape!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!Free social bookmarking plugins and extensions for Joomla! websites!
 
< Prev   Next >

Thoughts for the Week

Copyright © 2008 John Kolbert. Visit the original article at http://simply-basic.com/general/thoughts-for-the-week/.
Well another week down, and what a week it has been! Not only has it been busy…     Readmore

WP Advanced Code Editor

Copyright © 2008 John Kolbert. Visit the original article at http://simply-basic.com/announcements/wp-advanced-code-editor/.
For those interested, I wrote a plugin for Techlyzer.com that was just released. It’s called     Readmore

Check Out My Other Home: Techlyzer.com

Copyright © 2008 John Kolbert. Visit the original article at http://simply-basic.com/general/check-out-my-other-home-techlyzercom/.
Hi all. I’m happy to announce the launch of a new website that I’ll be trying to…     Readmore

Gadget Advisor Blog

Copyright © 2008 John Kolbert. Visit the original article at http://simply-basic.com/reviews/gadget-advisor-blog/.
Being a tech-centric blog I’m always on the lookout for other technology related websites. For those with…     Readmore

Updates to Permalinks

Copyright © 2008 John Kolbert. Visit the original article at http://simply-basic.com/announcements/updates-to-permalinks/.
After a lot of deliberation I’ve changed the permalink structure of Simply-Basic. When I started the blog…     Readmore

Qwest Web.Help: Stop Hijacking My Browser (How to Opt-Out)

Copyright © 2008 John Kolbert. Visit the original article at http://simply-basic.com/posts/1941493.
Earlier today I was surfing the web and mistyped a URL. Rather then getting the customary “The…     Readmore

Change Default File Type and Path for Screen Captures [Mac Tips]

Copyright © 2008 John Kolbert. Visit the original article at http://simply-basic.com/posts/1941482.
Mac only - I frequently use Mac’s built in screen capture ability to create the images you…     Readmore

Coming Soon: Comment on Lifehacker Using Your Facebook ID

Copyright © 2008 John Kolbert. Visit the original article at http://simply-basic.com/posts/1941478.
I just noticed that Lifehacker is joining the ranks of sites using the new Facebook Connect,…     Readmore

dealdotcom
Earn $$ with WidgetBucks!