際際滷

際際滷Share a Scribd company logo
FirePHP An extension to FireBug油 for油 AJAX Development
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/
FirePHP Requirements Firefox with the FireBug extension with the NET tab enabled PHP 4 or PHP 5 Output Buffering must be used.
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
Hello World require_once ( 'FirePHPCore/FirePHP.class.php' ) ;  $firephp   =  FirePHP :: getInstance ( true ) ; ob_start(); $firephp -> info ( 'Hello World' ) ;  ob_end_flush ();
油
The actual headers for the example油油 油 The data is passed back to the browser in the Headers.
The basic calls $firephp->log('Hello World'); $firephp->info('Hello World'); $firephp->warn('Hello World'); $firephp->error('Hello World');
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::   }
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' )) ;
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 ) ;
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' ) ;
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 ) ;
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); }
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

More Related Content

FirePHP

  • 1. FirePHP An extension to FireBug油 for油 AJAX Development
  • 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
  • 5. Hello World require_once ( 'FirePHPCore/FirePHP.class.php' ) ; $firephp = FirePHP :: getInstance ( true ) ; ob_start(); $firephp -> info ( 'Hello World' ) ; ob_end_flush ();
  • 6.
  • 7. The actual headers for the example油油 油 The data is passed back to the browser in the Headers.
  • 8. The basic calls $firephp->log('Hello World'); $firephp->info('Hello World'); $firephp->warn('Hello World'); $firephp->error('Hello World');
  • 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