FirePHP

Permalink
Is anyone using this PHP debug tool from Mozilla? I notice the Wiki Server Libraries (http://www.firephp.org/Wiki/ ) have everyone under the sun EXCEPT Concrete5. Is there any solution or advice on this?

Ricalsin
 
Mnkras replied on at Permalink Reply
Mnkras
interesting, i just use Log::add though :)
jbx replied on at Permalink Reply
jbx
You need to have the extension installed (https://addons.mozilla.org/en-US/firefox/addon/6149/eula/71900?src=addondetail) and the pear library installed
# pear channel-discover pear.firephp.org
# pear install firephp/FirePHPCore
for this to work. Also, output buffering needs to be turned on in your php.ini. Assuming all of that, create a new helper called jbx_firephp.php.

Add the following code:
<?php defined('C5_EXECUTE') or die(_("Access Denied."));
require_once('FirePHPCore/FirePHP.class.php');
class JbxFirephpHelper {
    public function log($var) {
        $firebug = new FirePHP();
        $firebug->getInstance(true);
        $firebug->log($var);
    }
}


Then, anywhere on your site, you can do this:
<?php JbxFirephpHelper::log($variable) ?>


I did also get it working with exceptions, however, it slowed everything down massively! Randomly chucking out vars to firebug is brilliant though. I used to just die(var_dump($var)); all of the time, which is a real pain. And with concrete's built in logger, although it is very good, it's not quite as tidy as having everything there in Firebug. I like it :)

Jon
jbx replied on at Permalink Best Answer Reply
jbx
<?php defined('C5_EXECUTE') or die(_("Access Denied."));
require_once('FirePHPCore/FirePHP.class.php');
class JbxFirephpHelper {
    public function log($var, $type = null) {
        $firephp = FirePHP::getInstance(true);
        switch($type) {
            case 'log'       : $firephp->log($var); break;
            case 'info'      : $firephp->info($var); break;
            case 'warn'      : $firephp->warn($var); break;
            case 'error'     : $firephp->error($var); break;
            case 'dump'      : $firephp->dump($var); break;
            case 'trace'     : $firephp->trace($var); break;
            case 'exception' : $firephp->error($var); break;
            case 'table'     : $firephp->table('Output:', $var); break;
            default          : $firephp->log($var, $type); break;


Be warned tho, as I mentioned above, sending exceptions or traces can be very slow. They do work, just may take 30s to a minute to process...

Jon
Ricalsin replied on at Permalink Reply
Ricalsin
Sweet! (-; Great tool for working on a remote site. Thanks for your time and sharing this.

Thanks Jon
cadorn replied on at Permalink Reply
There are some solutions to reducing the volume of data when sending exceptions and traces:

http://www.christophdorn.com/Blog/2010/10/15/tip-firephp-data-volum...
MrNiceGaius replied on at Permalink Reply
MrNiceGaius
Thanks Jon, this helper is great. Works perfect for my theme files but I'm having trouble getting it to work with my blocks edit.php file. Is it something related to the Ajax loading?

here's the error:
Fatal error: Uncaught exception 'Exception' with message 'Headers already sent in /Applications/MAMP/htdocs2/AIBB/concrete/elements/dialog_header.php on line 2. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.'

I have ob_start(); in my theme's header.php file... but still this error.

How to do debugging with FirePHP within a block's add/edit.php file?


update: was due to a random ob_end_flush() call before the firephp :)
nerdess replied on at Permalink Reply
nerdess
I am trying to get FirePHP to work with your little helper but my Firebug console remains empty, nothing gets logged....

Here my specs:
Firefox 8.01
Firebug 1.8.4
FirePHP 0.6.2
Plus I've enabled output_buffering in my php.ini

?!?!? :-/
nerdess replied on at Permalink Reply
nerdess
Oh false alarm........my fault.........the network panel was not enabled in Firebug, sorry ;-)

It works fine now.
marcus30 replied on at Permalink Reply
Another way to get FirePHP working is to just drop the downloaded files into your libraries folder, then load it:

Loader::library('FirePHPCore/fb');


You can then use FirePHP normally, without having to create your own helper.
marcus30 replied on at Permalink Reply
And an even simpler way to get it working is to just require it in the root index.php file.
require('libraries/FirePHPCore/fb.php');
require('concrete/dispatcher.php');


Now you have FirePHP available to you globally, without having to load it every time you want access it.