2. What is FirePHP FirePHP enables you to log to your油 FirebugConsole 油using a simple PHP method call. All data is sent via response headers and will not interfere with the content on your page. FirePHP is ideally suited for AJAX development where clean JSON and XML responses are required. http://www.firephp.org/
3. FirePHP Requirements Firefox with the FireBug extension with the NET tab enabled PHP 4 or PHP 5 Output Buffering must be used.
4. Installing Fire PHP First, install Firebug. Then install the FirePHP FireFox addon. 油油 油 https://addons.mozilla.org/en-US/firefox/addon/6149 Download the PHP library 油油 油 http://www.firephp.org/HQ/Install.htm Or using PEAR pear channel-discover pear.firephp.org pear install firephp/FirePHPCore
9. Custom Error, Exception, & Assertion Handling You can cause PHP to log errors to FirePHP instead of the normal error log file easily. $firephp -> registerErrorHandler ( $throwErrorExceptions = true ) ; $firephp -> registerExceptionHandler () ; $firephp -> registerAssertionHandler ( $convertAssertionErrorsToExceptions = true , $throwAssertionExceptions = false ) ; try { throw new Exception ( 'Test Exception' ) ; } catch ( Exception $e ) { $firephp -> error ( $e ) ; // or FB:: }
10. Groups & Nested levels You can add grouping and nested levels of groups to your FirePHP output. $firephp -> group ( 'Test Group' ) ; $firephp -> log ( 'Hello World' ) ; $firephp -> groupEnd () ; 油 $firephp -> group ( 'Collapsed and Colored Group' , array ( 'Collapsed' => true , 'Color' => '#FF00FF' )) ;
11. Data Tables You can even display Data Tables using FirePHP. $table = array () ; $table [] = array ( 'Col 1 Heading' , 'Col 2 Heading' ) ; $table [] = array ( 'Row 1 Col 1' , 'Row 1 Col 2' ) ; $table [] = array ( 'Row 2 Col 1' , 'Row 2 Col 2' ) ; $table [] = array ( 'Row 3 Col 1' , 'Row 3 Col 2' ) ; 油 $firephp -> table ( 'Table Label' , $table ) ;
12. Tracing You can manually call a trace. Normal calls also have a trace built into them when you hover over/click on the messages on the right side bar. $firephp -> trace ( 'Trace Label' ) ;
13. Variable Dumping You can dump a variable to the NET tab. I personally prefer to put one into a grouped alert call so you don't have to go clicking after it in another tab. $firephp -> dump ( 'REQUEST' , $_REQUEST ) ;
14. Security FirePHP CAN reveal油important油'stuff' to any web browser with FirePHP installed. Please take steps to insure your data and application security. Remove FirePHP from the live server Restrict access to authorized users only Restrict access to authorized IP addresses only require_once('FirePHPCore/FirePHP.class.php'); require_once('FirePHPCore/fb.php'); $firephp = FirePHP::getInstance(true); if(in_array( $my->id, array('000', '001') ) ) // Hard Coded Joomla User ID's { $firephp->setEnabled(true); } else { $firephp->setEnabled(false); }
15. FirePHP isn't just for Debugging You can do more then just debug code with FirePHP. You can display anything that you want to keep hidden from normal users. Current logged in users Last actions by users Server Statistics Code Profiling Code Decision Tree logic choices Additional information such as calculation intermediaries Design notes about the page TODO notes Reminder to get the milk on the way home Hire notices for anybody looking at the console on your site