Development

Introduction to FirePHP

FirePHP is a great tool for debugging PHP, and maintaining some level of control over your error handling. Also, it’s a great tool for getting information about your variables, objects, etc. while your PHP code is executing. FirePHP requires only a small amount of setup and can be reused time and time again without tedious setups for each site on your server. This tutorial/example requires Firefox and Firebug, and FirePHP.

  1. Install the Firebug add-on for Firefox
    http://getfirebug.com/
  2. Install the FirePHP add-on for Firefox
    https://addons.mozilla.org/en-US/firefox/addon/6149
  3. Download the FirePHP class
    http://www.firephp.org/HQ/Install.htm
  4. Unzip the FirePHP class, then move the contents of the lib/FirePHPCore directory into a folder on you webserver. If this folder is accessible to all of your websites on your server, you’ll be able to use this one FirePHP codebase for all of your sites. If you cannot “reuse” a folder like this, you’ll just need to have the FirePHP code base in each site with which you want to use FirePHP. In the examples below, I’m using a path that’s always available to me: /Users/adam/Sites/_includes/firephp/FirePHP.class.php. The bold part of the path is a directory that contains the files that were inlib/FirePHPCore.
  5. Create an include file you reuse in each site
  6. Create a PHP file to test FirePHP

If you have any problems, try the following. If you still have problems, Google It! 🙂

  • Start output buffering using ob_start(); (if output_buffering isn’t set to ‘on’ in your php.ini, .htaccess, etc.)
  • Enable the Firebug NET and CONSOLE panels
  • Check file permissions; make sure all of the files you’re accessing are readable by the web server

I’ve only shown a few of the possibilities in the example above. Please consult the FirePHP usage page for more features, and a much more thorough explaination of things.

The image below shows the output of the example code above.

firephp

One Comment

Leave a Reply

Your email address will not be published.