firebug and firephp

35
Firebug Extension for AJAX Development Zend_Log

Upload: david-stockton

Post on 17-Jan-2015

5.453 views

Category:

Technology


0 download

DESCRIPTION

Why you should use Firebug and FirePHP if you're a PHP programmer.

TRANSCRIPT

Page 1: FireBug And FirePHP

Firebug Extension forAJAX Development

Zend_Log

Page 2: FireBug And FirePHP

• If you’re not using Firebug when coding for the web, you’re missing out...

• And making it harder on yourself...

• For no good reason

Page 3: FireBug And FirePHP

• Debugger

• Real-time HTML/DOM editing

• Real-time CSS editing

• Request/Response/Network Analysis

• Interactive Javascript

• Great Plug-ins, like FirePHP and YSlow

Page 4: FireBug And FirePHP

• Getting Started

• getfirebug.com

• Inactive

• Active

Page 5: FireBug And FirePHP

Interactive Console

Page 6: FireBug And FirePHP
Page 7: FireBug And FirePHP

• Network Analysis

Page 8: FireBug And FirePHP

Drill-down

Page 9: FireBug And FirePHP

• Real-time HTML editing

• Was not working for me when I tried it, but I have done it before. It should work.

• Real-time CSS editing

• Also not working when I put this together

• But, normally they work and are AWESOME!

Page 10: FireBug And FirePHP

Interactive JS Debugger

Breakpoints

Watch List

Variable Inspector

Stack Inspector

Page 11: FireBug And FirePHP

• Getting Started

• www.firephp.org

FirePHPFirebug Extension forAJAX Development

Page 12: FireBug And FirePHP

• Two parts:

• Browser plug-in

• PHP API

FirePHPFirebug Extension forAJAX Development

Page 13: FireBug And FirePHP

• Standalone Library

• Zend_Log_Writer_Firebug

• Zend_Db_Profiler_Firebug

• Other Integrations: Agavi, BIGACE, CakePHP, CodeIgniter, Drupal, ExpressionEngine, eZ, Joomla, Kohana, Nette Framework, PEAR, PRADO, Probus, Project Zero, REDAXO, Seagull

FirePHPFirebug Extension forAJAX Development

Page 14: FireBug And FirePHP

Standalone Library

Page 15: FireBug And FirePHP

Standalone Library

Page 16: FireBug And FirePHP

That’s the beginning

Member variable filtersLog your classes, but hide sensitive data automatically

Page 17: FireBug And FirePHP

Exception Handling

Page 18: FireBug And FirePHP

Exception Stack Trace

Page 19: FireBug And FirePHP

Error Handler

Page 20: FireBug And FirePHP

Assertion Handler

Assert fail still shows warning...

Page 21: FireBug And FirePHP

Message Groups

Page 22: FireBug And FirePHP

Log Tables of Data

Page 23: FireBug And FirePHP

Variable Dumping (var_dump ++)

Where is it???In the Server part of the Net request:

Page 24: FireBug And FirePHP

Zend Framework

• Doesn’t require you to download the standard library

• Protocol is built into Zend Framework

• Use it with Zend_Log

• Use it with Zend_Db_Profiler_Firebug

Page 25: FireBug And FirePHP

Zend Framework

Page 26: FireBug And FirePHP

• Zend_Log works using the Observer pattern

• Log writers are added to Zend_Log

• Each writer can log different levels, to different places, using different methods

• i.e., file, database, Twitter, or FirePHP

Zend Framework

Page 27: FireBug And FirePHP

Zend Framework

• Create your writer

• Add the writer to the Zend_Log object

• Do this in your bootstrap before dispatch

Page 28: FireBug And FirePHP

Zend Framework

• Zend_Log lets you set your own logging levels and map those to FirePHP log types

• $logger->addPriority('ULTRA', 8);

• $writer->setPriorityStyle(8, 'TRACE');

• $logger->ultra('Ultra Message - With trace');

Page 29: FireBug And FirePHP

• Logging exceptions happens automatically

• Just pass the Exception object and FirePHP will show the exception and stack trace

• Zend_Log, like log4j, lets you set up multiple writers, with global or local filters, formats, etc

• One log call can result in many logs in many places if that’s what you want

Zend_Log

Page 30: FireBug And FirePHP

How it all works

• FirePHP sends data using HTTP headers

• It detects FirePHP running. If it’s not there, it sends nothing

• Sniff the wire in IE. Nothing there.

Page 31: FireBug And FirePHP

With great power...

• FirePHP logging is very powerful and very useful.

• If someone is looking at your site with FirePHP installed, they will see your messages... unless...

Page 32: FireBug And FirePHP

A couple of options• Turn off logging in production

• $writer->setEnabled(false);

• Turn off logging in production, but enable if users who should be able to see this stuff are logged in

• Allows developers to “debug” in production

• “Debugging” in production requires smart logging

Page 33: FireBug And FirePHP

Smart Logging

• Logs can help you track down exactly what happened

• Or they can be confusing and useless

• File logging is a must when you need to track down problems after they happened and reproducing the problem is difficult, expensive, or impossible

Page 34: FireBug And FirePHP

FirePHP Logging

• FirePHP logs are temporal

• More detail can be useful for FirePHP logs than would be practical with file logs

• Zend_Log means you don’t need to make more than one log call

• Use filters/priorities to determine if you want FirePHP, file logging, or both