CodeIgniter 3 and FirePHP

Classified in : Uncategorized - Tags : none

The latest version of CodeIgniter is out (v 3.0.0): it brings some interesting new features.

So, it's the opportunity for a little tutorial to instal FirePHP as all the links on the wiki are dead.

FirePHP is a library that allows not really to debug (no break points etc) but to trace and log messages that will be easily read in the Firebug console !

It's not a major improvement to the messages that can be logged with the log_message function of CodeIgniter ... other than that the message is not logged into a file that must be opened: with FirePHP, messages land directly in the Firebug console which is really handy !

Here are the steps to add FirePHP to CodeIgniter :

  1. Download FirePHP core (at the moment, it's version 0.3.2).
  2. Unzip the archive and rename the file /lib/FirePHPCore/FirePHP.class.php to /lib/FirePHPCore/FirePHP.php .
  3. Copy the file /lib/FirePHPCore/FirePHP.php in CodeIgniter directory application/libraries.
  4. Add firephp in the array of $autoload['libraries'] of file application/config/autoload.php (line 63). For instance, you get a line like this:
    $autoload['libraries'] = array('database','firePHP');
  5. Then you only need to log some calls to get values displayed in the Firebug console, like:
    $this->firephp->log('my string message' );
    $this->firephp->log($myVar );
  6. Verify that Network panel is enabled and enable All messages on the Console: that's where the message will be displayed !

That's it !

 WATCH OUT :

If, when using FirePHP, you get a message in the browser "The connexion has been reinitialised" (or some thing like that), then it could be a problem in FirePHP. Just deactivate it, and you will be fine (at least without this error).

EDIT April 20th :  We may also use the Profiler class from CodeIgniter (check out CodeIgniter documentation for more info), by typin (anywhere in the controler):

$this->output->enable_profiler(TRUE);

Happy Debugging ! wink

[ 3 comments ]

© Le Computing Froggy  !

3 comments

Write a comment

What is the last letter of the word guide2k? :