FirePHP: Unobtrusive PHP Debugging

 

Today, I will uncover the newest debugging tool that I have added to my toolbox. It happens to be the FirePHP extension for Firebug. In this article I will give you an overview of what FirePHP is, why it is beneficial, and finally how to get started using it!

FirePHP Overview

FirePHP is an AJAX Development / PHP debugging tool. It is used as an extension to Firebug, the must-have web development Firefox plug-in. It allows you to log text and variables to your console similar to how you would using JavaScript’s “console.log”.

Why use it?

Using FirePHP means that that you can debug a live site without affecting the actual website content. Obviously you want to stay away from this as much as possible, but the situation will arise at one time or another.

Many times I would have liked to “echo” out a variable to see if it is causing the problem, but you can’t do this on a live site. Now you can use this plug-in to redirect debugging data to the console that normal users will never see.

It also has an advanced variable viewer, and logging capabilities.

Let’s Get Started!

In order to use FirePHP there are two components you need to take care of; one being the client-side and the other being the server-side. The client-side is simple enough as all you need to do is download and install the extension like you would for any other Firefox add-on.

One this is done, open up Firebug (F12) and check if there is a blue bug beside the normal Firefox one. If this is the case you have the browser ready.

FirePHP logo

Now this is the part which is a bit of a pain, because this needs to be done on every server you work with. You will need to download the FirePHPCore server-side library. You then need to upload the FirePHPCore folder to your server, which is located in the lib folder. This can be placed in a non web accessible folder to make it available on all sites under that one server using an absolute path.

Now we should have everything setup, let’s test it out:

< ?php
	require_once('/home/user/FirePHPCore/FirePHP.class.php');

	$firephp = FirePHP::getInstance(true);
	$firephp->warn('test');
?>

Once this is uploaded, you can browse to it and see the word ‘test’ in the console. There are many other ways to debug your variables. To view a complete list, visit the official usage page.

FirePHP Warn

Related posts:

  1. Debugging: The most important tool in your toolbox
  2. Unobtrusive JavaScripting


Written by Brenley Dueck

 

2 Responses to “FirePHP: Unobtrusive PHP Debugging”

  1. unset Says:

    January 27th, 2009 at 7:22 am

    I use FireBug since the corresponding logger was added to the ZendFramework. Unfortunately I cannot convince the ClientSide AddOn to display the amount of Warnings/Notices without pop up the full panel :-(

  2. Sean Nieuwoudt Says:

    January 27th, 2009 at 1:37 pm

    FirePHP is ok, but I’ve written my own debugging framework with a server listening for socket connections written in python running on one machine and a client running alongside my php apps… all output is sent through to the server and logged/displayed as needed… I find it much more flexible than in-browser debugging.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 
connect with me!