FirePHP is an addon for FireBug extension for Firefox browser.
FirePHP extends FireBug functionalities to show log or error messages coming from your PHP application. These messages won’t be printed on the application interface but instead on the FireBug console.
What do you need to integrate this debugging feature in your application :
The next step is to open Firefox and visit the url where your application is located and activate the Net panel in FireBug, clicking the bottom right Firebug icon in Firefox window.

The client (the browser), is now ready to accept the debugging messages, we have now to integrate the FirePHP library with the CodeIgniter application on server side :
- dowload the FirePHP Core Library from here
- extract the
FirePHP.class.phpfrom the archive, rename it tofirephp.phpand copy in thesystem/application/librariesdirectory of your CodeIgniter application
Now you can use FirePHP to debug your code :
- load the library :
$this->load->library('firephp') - send debug messages to the FireBug console :
$this->firephp->log($myvariable)or$this->firephp->error('Error at this line')
Detailed instructions to use FirePHP are available on FirePHP project website. The most useful method for me are :
$this->firephp->log($myvariable): send a dump of the variable$myvariableon the FireBug console$this->firephp->warn($myvariable): send a dump of the variable$myvariableon the FireBug console classified as a warning$this->firephp->error($myvariable): send a dump of the variable$myvariableon the FireBug console classified as an error
Here there is a little example on how you can use FirePHP with CodeIgniter :
<?php $this->load->library('firephp'); $myvariable = array ( 'language' => 'PHP', 'database' => 'MySQL', 'blogging platform' => 'WordPress', 'post' => 'CodeIgniter and FirePHP', ); $this->firephp->log($myvariable); ?>
And this is the output on the Firefox’s FirePHP console :

The debug messages can be disabled with the method : $this->firepgp->setEnabled(FALSE).
It is also possible to make the messages appear only for specific ip addresses :
<?php if($this->input->ip_address() =='1.2.3.4') { $this->firephp->setEnabled(TRUE); } else { $this->firephp->setEnabled(FALSE); } ?>
Suggested books
{ 21 comments }
