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
require_once($yii);
~~~
Add the following code:
~~~
[php]
if (YII_DEBUG){
Yii::import("application.components.FirePHPCore.fb", true);
}
~~~
So, you will have (in 1.0.x version)
~~~
[php]
require_once($yii);
if (YII_DEBUG){
Yii::import("application.components.FirePHPCore.fb", true);
}
Yii::createWebApplication($config)->run();
~~~
(1.1.x version)
~~~
[php]
$app = Yii::createWebApplication($config);
if (YII_DEBUG){
Yii::import("application.components.FirePHPCore.fb", true);
}
$app->run();
~~~
That's it! Now you can display your variables on FirePHP with a simple 'fb' command inside your PHP code:
[php] fb($my_variable); ~~~
To view the results, open Firebug at 'console' tab and run your PHP file.
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
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
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')) {
for
if(!class_exists('FirePHP',false)) {
to prevent the autoload error in class_exists function
Solved
In Controller.php located in protected/components, put the following code;
public function init(){ parent::init(); if(YII_DEBUG){ spl_autoload_unregister(array('YiiBase','autoload')); require_once (dirname(__FILE__).'/../components/FirePHPCore/fb.php'); spl_autoload_register(array('YiiBase', 'autoload')); } }
use fb() in throughout program with dont comment that
Hi,
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:
require_once($yii); $app = Yii::createWebApplication($config); Yii::import("application.components.FirePHPCore.fb", true); $app->run();
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.
Thanks
Nabi
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.