Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

firephp

posted by martin santangelo 10 years ago

I use firephp in my projects to send debug data without breaking the html or ajax response. An integration into flourish fCore for debugging will be a great feature I think. http://www.firephp.org/

Regards

I looked into FirePHP some and it certainly does look like a useful bit of functionality.

Most of Flourish is built in a way that functionality can be injected via use of callbacks. While there currently is no way to register a callback for use with fCore::debug(), that may be a useful feature to add.

With such a callback interface, it would be possible to intercept the debug messages and then pass them off to FirePHP. If this is something you think you would find useful you should file a ticket requesting such an enhancement. With a ticket, you and I can both track the status of adding the enhancement.

posted by wbond 10 years ago

For future readers reference, Martin filed ticket #136 and the static method fCore::registerDebugCallback() was added in r508. Documentation about how to use it is included on the fCore class documentation page.

posted by wbond 10 years ago

Thank you, that was fast.

posted by martin santangelo 10 years ago

I still can't figure out how to get FirePHP to actually work with flourish. I've setup flourish to register a debug callback function :

fCore::registerDebugCallback('handleDebug');

I've setup a simple function to display the output as plain text and with fb():

function handleDebug($message)
{
    // Code to pass message to another debugging or logging system
	fb($message);
	echo $message;
}

I call the request debug output:

fCore::debug('My Test Error Message', TRUE);

I get the correct HTML output. However, there is no info in FireBug.

Does anyone have suggestions?

FYI : Yes, FirePHP is included in my setup.

require_once( APP_PATH . '/FirePHPCore/fb.php');
posted by appbeacon 10 years ago

i had similar problems and i had fun figuring out why firephp was so quirky. i think those guys like being... obtuse.

in any case, here's what i came up with using their OO methods:

fCore::enableDebugging(TRUE);
fCore::registerDebugCallback('trace_debug');

function trace_debug($msg){

	// check that FirePHP is loaded
	if(!class_exists('FirePHP'))
		// class not found, load it
		include('fb.php');

	// get FirePHP instance
	$firephp = FirePHP::getInstance(TRUE);

	// send trace
	$firephp->trace($msg);

}

That's easy, but it wasn't really the problem. FirePHP has fallen behind on keeping up with Firebug development. FirePHP 0.3 just came out which *kind of* works with the recent Firebug alphas, but you have to have Firebug open to the Net panel. Once the page loads, switch over to the Console panel and you'll see all your debug traces.

posted by vena 10 years ago

Vena,

The last time I tried your suggestion (I am AppBeacon in the messages above), I still couldn't get it to work. Since then, I've been muddling through debugging with echos and prints. I'd sort of forgotten all about firephp.

Lately, I've been getting irked by my troubleshooting issues and rediscovered FirePHP. I FINALLY figured out how to get FirePHP to work with flourish. It's almost the same as yours. Thanks for the directions. For some reason, I could not get your method to work without first including require_once(APP_PATH . '/FirePHPCore/FirePHP.class.php'); before enabling debugging. No matter what I did with my autoload function, I couldn't get flourish to load FirePHP.

/**
 * Setup firebug
 */
require_once(APP_PATH . '/FirePHPCore/FirePHP.class.php');
fCore::enableDebugging(TRUE);
fCore::registerDebugCallback('trace_debug');
 
function trace_debug($msg)
{
	// check that FirePHP is loaded
	if(!class_exists('FirePHP'))
	{        
		// get FirePHP instance
		$firephp = FirePHP::getInstance(TRUE);
	}
	require_once(APP_PATH . '/FirePHPCore/fb.php'); 

	// Send the trace
	FB::send($msg);
}

When you need to output debug info, do the following:

fCore::debug('Test debug info here.');
posted by justbn 9 years ago