Presentation is loading. Please wait.

Presentation is loading. Please wait.

{ Debugging PHP with Xdebug Stephanie Russell Zachary Klink.

Similar presentations


Presentation on theme: "{ Debugging PHP with Xdebug Stephanie Russell Zachary Klink."— Presentation transcript:

1 { Debugging PHP with Xdebug Stephanie Russell Zachary Klink

2  Free and open source Swiss army knife for PHP developers.  Developed by Derick Rethans  Written in C  Initial release date: May 2, 2002  Stable Release: 2.1.2; July 28, 2011 Xdebug

3  Stack and function traces in error messages  Full param display for user defined functions  Function name, file name and line number  Support for member functions  Memory allocation  Protection for infinite recursions  Profiling information for PHP scripts  Code coverage analysis  Debugger front-end to interactively debug Features

4  DBG  FirePHP  Gubed  PHP_Debug  MacGDBp Competition

5  Performance  Pause program execution  Usable with Eclipse, Netbeans, Notepad++, Chrome, Firefox, etc. Why Xdebug?

6 { Let’s dive a little deeper… How to Xdebug

7  php.ini  When enabled, xdebug controls program execution.  As a server  GDB and DBGp  Remote control for PHP  Embedded into editor (no direct dealing with protocol itself) How to Xdebug

8  Modes:  Default: req. Makes xdebug always connect to client when a script is started.  Second mode: jit. Only connect to the client on a breakpoint or error in script.  No setting in xdebug.remote_mode = default How to Xdebug

9  Negatives  Potential install/configuration nightmare  Compatibility issues Drawbacks

10 { How it works! Internals

11  With remote debugging, embedded Xdebug in PHP acts as a client, and the IDE acts as a server. Internals – single dev  The IP of the server is with HTTP on port 80  The IDE is on IP , so xdebug.remote_host is set to xdebug.remote_host  The IDE listens on port 9000, so xdebug.remote_port is set to 9000 xdebug.remote_port  The HTTP request is started on the machine running the IDE  Xdebug connects to :9000  Debugging runs, HTTP Response provided

12  Setup is only slightly different: Internals – multiple dev  The IP of the server is with HTTP on port 80  The IDE is on an unknown IP, so xdebug.remote_connect_back is set to 1 xdebug.remote_connect_back  The IDE listens on port 9000, so xdebug.remote_port is set to 9000 xdebug.remote_port  The HTTP request is made, Xdebug detects the IP address from the HTTP headers  Xdebug connects to the detected IP ( ) on port 9000  Debugging runs, HTTP Response provided

13 Internals – Debug session  Tracks debug session through brower: cookies  URL variable XDEBUG_SESSION_START=name appended to URL  Xdebug emits cookie with name “XDEBUG_SESSION” with value “name.”  This expires in an hour.  DBGp protocol also passes this value to the init packet when connecting to debug client

14 Internals – Debug session  When there is a GET or POST, the cookie is set, xdebug connects to a debug client.  To stop debug session (and destroy the cookie), add URL parameter XDEBUG_SESSION_STOP.  Xdebug not longer tries to connect to debug client.

15 Internals – Multiple Users  Can specify one IP or multiple users  xdebug.remote_host or  If IP not known: xdebug.remote_connect_back

16 { Be sure to wear your helmet. Installation

17  PHP 5  Apache2 First

18  Apt-get  Compatibility with PHP release  Find installed xdebug.so  Edit php.ini file to add zend extension.  Remote host/port  Known IP (edit 09/22 or for multiple developers)  Port open Install

19  Netbeans Tools > Options > PHP  Set debug port = remote_port Integrate with Netbeans

20 { Valiantly attempting to avoid Murphy’s law Demo

21 { Research is key to success Resources

22   to-debug-php-using-firefox-with-firephp/ to-debug-php-using-firefox-with-firephp/ to-debug-php-using-firefox-with-firephp/    0/50-extremely-useful-php-tools/ 0/50-extremely-useful-php-tools/ 0/50-extremely-useful-php-tools/  Competition Resources

23    / / /  for-php-on-debian-ubuntu.html for-php-on-debian-ubuntu.html for-php-on-debian-ubuntu.html  environment-ubuntu.html environment-ubuntu.html environment-ubuntu.html   debug-php-with-netbeans-and-xdebug debug-php-with-netbeans-and-xdebug debug-php-with-netbeans-and-xdebug  heck_xdebug_installation heck_xdebug_installation heck_xdebug_installation Installation Resources

24  Everything Else Resources


Download ppt "{ Debugging PHP with Xdebug Stephanie Russell Zachary Klink."

Similar presentations


Ads by Google