Yii 1.1: Integrating FirePHP

  • Install Firebug plugin for Firefox from here.

  • Install FirePHP plugin for Firefox from here.

  • Download FirePHP package from here.

  • Extract 'FirePHPCoreXXX/lib/FirePHPCore' compressed folder to '/path/to/protected/components/FirePHPCore' folder.

  • At /path/to/index.php, after the line


    Add the following code:

    if (YII_DEBUG){
        Yii::import("application.components.FirePHPCore.fb", true);

    So, you will have (in 1.0.x version)

    if (YII_DEBUG){
        Yii::import("application.components.FirePHPCore.fb", true);

    (1.1.x version)

    $app = Yii::createWebApplication($config); 
    if (YII_DEBUG){
        Yii::import("application.components.FirePHPCore.fb", true); 

    That's it! Now you can display your variables on FirePHP with a simple 'fb' command inside your PHP code:


To view the results, open Firebug at 'console' tab and run your PHP file.

Total 5 comments

#15910 report it
Nabi at 2013/12/28 02:14pm
use fb() in throughout program with dont comment that


Thanks for great article.

If you want to use fb() in throughout program with dont comment that function and dont worry about forgot this work. use this:

1) in index.php file, dont check YII_DEBUG, and have this code:

$app = Yii::createWebApplication($config);
Yii::import("application.components.FirePHPCore.fb", true);

2) in FirePHPCore/fb.php file, you check YII_DEBUG before create instance of FirePHP. have this code:

function fb()
    if (!YII_DEBUG) return; //customize by Nabi
    $instance = FirePHP::getInstance(true);
    $args = func_get_args();
    return call_user_func_array(array($instance,'fb'),$args);

After this, every time you can use fb() function without comment it after end project! and just you can disable YII_DEBUG in index.php if you can disable FirePHP.



#13365 report it
Leandro Tec Can at 2013/05/24 02:23pm

In Controller.php located in protected/components, put the following code;

public function init(){
        require_once (dirname(__FILE__).'/../components/FirePHPCore/fb.php');
        spl_autoload_register(array('YiiBase', 'autoload'));
#9072 report it
ikary at 2012/07/17 06:06pm
firephp 0.3.2 + php5 + yii 1.1.10

in /path/to/protected/components/FirePHPCore/fb.php, line 45, change this

if(!class_exists('FirePHP')) {


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

to prevent the autoload error in class_exists function

#4619 report it
Jonas at 2011/07/26 04:59pm
Get it to work with 1.1.8

I got the same error but the error message gives a clear hint where to look: In fb.php you need to comment line 45 and 47:

//if(!class_exists('FirePHP')) {
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'FirePHP.class.php';

Don't ask me why... but it works then. As already described you can add fb($variable) to your code and you will see its value in console>all

#4101 report it
Elson at 2011/06/06 02:26am
not work in yii 1.1.7

the page show php error after I modify the code in file "index.php "

include(FirePHP.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory

Leave a comment

Please to leave your comment.

Write new article
  • Written by: ricardograna
  • Category: Tutorials
  • Yii Version: 1.1
  • Votes: +8 / -1
  • Viewed: 14,272 times
  • Created on: Oct 5, 2010
  • Last updated: Oct 20, 2010