Mar 1, 2010
Codeigniter: Debugging with FirePHP
FirePHP “enables you to log to your Firebug Console using a simple PHP method call. All data is sent via response headers and will not interfere with the content on your page. FirePHP is ideally suited for AJAX development where clean JSON and XML responses are required.”
Using it with Codeigniter is very simple. First download FirePHP core library. Look inside newly downloaded zip file and extract from there FirePHP.class.php (you can find it inside FirePHPCore/lib/FirePHPCore/).
Rename FirePHP.class.php to firephp.php and move it or upload it to your Codeigniter system/application/libraries/ folder.
Using it is very simple. Just load it in your controller and start using it.
class Welcome extends Controller {
function __construct() {
parent::Controller();
$this->load->library('firephp')
}
function index() {
$this->firephp->log("Log");
$this->firephp->info("Info");
$this->firephp->error("Error");
}
}
Now take a look on FireBug console and you should see something like that
This is a basic example usage. A more advanced usage is available inside MY_Controller (enable it for certain ip or group log messages together).
Download MY_Controller (250)
