If you've ever had debugging statements decimate a layout, then you need
FirePHP. Like its brother-in-arms
FireBug, FirePHP is a Firefox Add-on designed to help PHP developers cleanly debug code. FirePHP can also me used to debug CakePHP applications with only a few additional lines of code.
- First, download and install the FirePHP add-on for Firefox.
- Then download the FirePHPCore package. Extract FirePHP.class.php to '/app/vendors/FirePHP'.
- Now download the FirePHP.debugger.php class(Don't worry about following any directions on this page). Place this file in '/app/vendors/FirePHP'.
-
In /app/config/bootstrap.php
ob_start();
-
In app_controller.php
function beforeFilter() {
App::import('Vendor', 'FirePHPDebugger', array('file' => 'FirePHP' . DS . 'FirePHP.debugger.php'));
App::import('Vendor', 'FirePHP', array('file' => 'FirePHP' . DS . 'FirePHP.class.php'));
$this->FirePHP = new FirePHP();
}
-
In your controller
$this->FirePHP->fb($varToDebug);
Now all the CakePHP debug statements and inline debugging (usually debug() is used) will run through FirePHP. A side effect is that no debugging will be printed on the screen by mistake on a live site. A visitor would have to be running FirePHP to even chance upon debugging.