Using FirePHP-Helper as a Debugger on CodeIgniter

September 19, 2012

Using FirePHP-Helper as a Debugger on CodeIgniter

FirePHP is a debugger to output/print any values to firebug console. Some nice features that you can use are message, label, and code tracing. If you usually use var_dump to develop PHP apps, FirePHP is a much handier for you.

There are some ways to integrate FirePHP to your CodeIgniter application. You can use class, as described in these articles: FirePHP with CodeIgniter and Fire Ignition, or use the CodeIgniter helper.

In this tutorial, we will cover how to use FirePHP via CodeIgniter helper. This method is much simpler than using class. You just drop firephp_helper.php and firephp library, then use autoload or load $this->load->helper('firephp') to call it, and call function fire_print() on-the-fly. For further details, let’s see how it goes!


Values, that you can pass, will be as string, array, object, json, or xml.



1. Install

And your file structure should look like this:

FirePHP File Structure

2. Usage

There are two ways to load this helper. You can add to application/config/autoload.php, or just open controller or model. If you haven’t put it on the autoload helper, you can use:


The FirePHP function parameter structure can be the following:

	$log_type could be: ‘log’, ‘info’, ‘warn’,’error’;
	$data could be: ‘string’,’array’,’object’,’json’,’xml’;

Fire_print($log_type, $data)

Open Firebug on your browser, then open the tab 'console'. Or, you can right click on web page -> inspect element -> console

On the php code call:


And the Firebug console should look like this:

Click on the console result to open the variable viewer.

Variable Viewer

Now, let’s try to output json and object.

json : using FirePHP to view data from twitter STREAMS API.



object : use FirePHP to see the output of objects from CodeIgniter Datamapper


CodeIgniter Datamapper

Tracing code execution:


FirePHP Trace

End Words

This FirePHP-helper is so much useful than the var_dump or print_r. It gives you the easier way to see the output and give label on log/warn/error, and is truly helpful for viewing the object and json data. This FirePHP-helper is also a great tool to see ORM/Datamapper object output, or RESTful API client, such as Facebook or Twitter.

Olivo Pablo's picture