Your SlideShare is downloading. ×
0
FirePHP
FirePHP
FirePHP
FirePHP
FirePHP
FirePHP
FirePHP
FirePHP
FirePHP
FirePHP
FirePHP
FirePHP
FirePHP
FirePHP
FirePHP
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

FirePHP

4,694

Published on

Mike Creuzer's presentation from the July, 2009 meeting of the Suburban Chicago PHP & Web Development meetup

Mike Creuzer's presentation from the July, 2009 meeting of the Suburban Chicago PHP & Web Development meetup

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
4,694
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 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

×