Yii 1.1: firephp-logroute

FirePHP log routes

FirePHP extension for Yii Framework

This extension contains 2 log route classes. The first, SK\Yii\FirePHP\LogRoute, processes standard Yii log messages. The second, SK\Yii\FirePHP\ProfileLogRoute, processes profile summaries. Both classes send all output to FirePHP. The classes work similarly to CWebLogRoute and CProfileLogRoute. The only major difference is the target output.

An advantage of using this extension is that logging and profiling work even through AJAX requests.


  • PHP 5.4+
  • A Yii Framework 1.1.14+ project.
  • Firebug and FirePHP plugins for Firefox. See http://firephp.org. Firebug's Console and Net tabs have to be enabled for this to work.
  • Set output_buffering setting to true in php.ini. You might also want to increase the buffer size to allow large log sizes.


The only supported installation method for now is using Composer.

  1. Put this in your composer.json and run composer update to install it:

      "require": {
        "shiki/yii-firephp": "dev-master"

    This will also automatically install the dependency firephp/firephp-core.

  2. Make sure you have loaded the Composer autoload file (vendor/autoload.php) so the libraries can be accessed in your Yii config file. See the main.php config file in the example project on how this can be done.

  3. Modify your config file (e.g. protected/config/main.php) to include the log route classes.

    'log' => array(
      'class' => 'CLogRouter',
      'routes' => array(
        // the default (file logger)
          'class' => 'CFileLogRoute',
          'levels' => 'error, warning',
        // standard log route
          'class' => '\\SK\\Yii\\FirePHP\\LogRoute',
          'levels' => 'error, warning, info, trace',
        // profile log route
          'class' => '\\SK\\Yii\\FirePHP\\ProfileLogRoute',
          'report' => 'summary', // or "callstack"

Standard logging

Once you've got the extension setup in the config, you can use Yii's logging methods to log messages to FirePHP.

// logging an INFO message
Yii::log('This is an info message.', CLogger::LEVEL_INFO);

// logging a WARNING message
Yii::log("You didn't setup a profile, are you really a person?", CLogger::LEVEL_WARNING);

// logging with a CATEGORY (categories are displayed as "labels" in FirePHP -- just an additional info text)
Yii::log('Profile successfully created', CLogger::LEVEL_INFO, 'application.user.profiles');

// tracing simple text
Yii::trace('Loading application.user.profiles.ninja', 'application.user.profiles');

// logging an ERROR
Yii::log('We have successfully determined that you are not a person',
  CLogger::LEVEL_ERROR, 'Any category/label will work');

// If you need to log an array, you can use FirePHP's core methods
FB::warn(array('a' => 'b', 'c' => 'd'), 'an.array.warning');

See more about logging here.


Profiling works by simply using Yii's profiling methods.

Yii::beginProfile('a somewhat slow method');

// some function calls here
// more function calls

Yii::beginProfile('nested profile');
// you can also nest profile calls
Yii::endProfile('nested profile');

Yii::endProfile('a somewhat slow method'); // end

You can also profile SQL executions. See more about that and profiling in general here.


To try all these out, there's an example project in the example folder. To run it:

  1. Install the required libraries using Composer.

    $ cd example
    $ composer install
  2. Run with the PHP built-in webserver

    $ cd example/webroot
    $ php -S localhost:8000
  3. Browse http://localhost:8000 in Firefox. Make sure first that Firebug is opened and the Console and Net tabs are enabled. You should be able to see the FirePHP logs in Firebug's console. If you don't, try refreshing first.


Please report issues on Github


Total 4 comments

#12821 report it
IRCSASW at 2013/04/13 11:53pm
bug fixed

PHP warning include(FirePHP.php): failed to open stream: No such file or directory

change line 45 \protected\extensions\firephp\firephp\lib\FirePHPCore\fb.php

if(!class_exists('FirePHP')) {


if(!class_exists('FirePHP',false)) {

now works perfect.

#9087 report it
ikary at 2012/07/18 12:46pm
and standard firephp commands

and if you add this import in the main.php


you can use normal firephp functions in the rest of your code :

FB::send("hello world to the firebug console");
#689 report it
Alec at 2010/03/18 03:48am

Please make a possibility to switch on/off logging all pdo queries (add a config option?) like in Zend Framework.

#742 report it
gazbond at 2010/03/08 06:24am

Nice extension, works great, setting 'output_buffering' to 'On' does slow things down quite a lot though. Good job!

Leave a comment

Please to leave your comment.

Create extension