6:24pm September 22, 2008
FirePHP + CakePHP = Great Debugging
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.

  1. First, download and install the FirePHP add-on for Firefox.
  2. Then download the FirePHPCore package. Extract FirePHP.class.php to '/app/vendors/FirePHP'.
  3. Now download the FirePHP.debugger.php class(Don't worry about following any directions on this page). Place this file in '/app/vendors/FirePHP'.
  4. In /app/config/bootstrap.php
    ob_start();
  5. 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(); }
  6. 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.
Views  951 Comments  0
Add Comment
View Chris Thompson's profile on LinkedIn
Loading...