1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Setting up the Debugger</title><meta name="generator" content="DocBook XSL Stylesheets V1.71.0"><link rel="start" href="index.html" title="Debugging in PHP Eclipse"><link rel="up" href="ar04.html" title="Debugging a Project On a Web Server Using PHPEclipse and XDebug"><link rel="prev" href="ar04.html" title="Debugging a Project On a Web Server Using PHPEclipse and XDebug"><link rel="next" href="ar04s03.html" title="Conclusion"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Setting up the Debugger</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ar04.html">Prev</a> </td><th width="60%" align="center">Debugging a Project On a Web Server Using PHPEclipse and
 
   2   XDebug</th><td width="20%" align="right"> <a accesskey="n" href="ar04s03.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="phpeclipse.debuggingremote.setupdebugger"></a>Setting up the Debugger</h2></div></div></div><p>Before we start debugging, we have to configure a few options so
 
   3     that PHPEclipse and XDebug know where to find various components.</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="phpeclipse.debuggingremote.setupdebugger.interpreterpath"></a>Specifying the PHP Interpreter Path</h3></div></div></div><p>To begin, we must specify the PHP Interpreter Path. This may
 
   4       differ depending on your system. For Windows based systems, this is a
 
   5       path to a file called php.exe. For Linux systems, this is a path to a
 
   6       file simply called php. For Linux systems, this is often in
 
   7       /usr/bin/php. To specify the PHP Interpreter, select Preferences from
 
   8       the Window drop down menu. Open up the PHPEclipse selection and click on
 
   9       XDebug. In the settings pane on the right that appears, enter your debug
 
  10       port and the path to your PHP interpreter. The default debug port for
 
  11       XDebug is 9000, but your system may be setup differently. To verify that
 
  12       9000 is the correct port, find a way to access your phpinfo() page and
 
  13       check the value of xdebug.remote_port. The value of xdebug.remote_port
 
  14       should match the debug port value.</p><div class="figure"><a name="phpeclipse.debuggingremote.xdebugsetup"></a><p class="title"><b>Figure 1. XDebug Configuration Pane</b></p><div class="figure-contents"><div class="screenshot"><div class="mediaobject"><img src="xdebugsetup.png" alt="XDebug Configuration Pane"></div></div></div></div><p><br class="figure-break">When you have entered the appropriate values, click on the OK
 
  15       button.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="phpeclipse.debuggingremote.setupdebugger.debugconfiguration"></a>Creating the Debug Configuration</h3></div></div></div><p>Now that we have configured XDebug, we need to create a debug
 
  16       configuration. This will tell Eclipse how to start the debugger for your
 
  17       project. To do this, select 'Open Debug Dialog' from the Run drop down
 
  18       menu. You will be presented with a list of items which you can debug.
 
  19       Double click on the entry titled 'PHP XDebug Remote Script'. This will
 
  20       create a new configuration and allow you to specify the necessary
 
  21       options. You can provide a name for your debug configuration, and then
 
  22       you must specify the Ide Identification String. You can select anything
 
  23       you want for this string. It is recommended to keep it short and
 
  24       memorable. Ensure that you remember this value for later. In our
 
  25       example, we will use the string firstproject.</p><div class="figure"><a name="phpeclipse.debuggingremote.debugconfigurationremote"></a><p class="title"><b>Figure 2. Debug Configuration Window</b></p><div class="figure-contents"><div class="screenshot"><div class="mediaobject"><img src="debugconfigurationremote.png" alt="Debug Configuration Window"></div></div></div></div><p><br class="figure-break">Once you have selected a configuration name and have chosen
 
  26       an identification string, click on the Pathmap tab. In the pathmap tab,
 
  27       you specify how Eclipse translates local path names to remote path
 
  28       names. To map a path, click on the New button to create a new map. If
 
  29       your web server is located on the same system that Eclipse is running
 
  30       on, both of these paths will be the same. In either case, under Local
 
  31       Path enter the path to the root of your project on the machine that
 
  32       Eclipse is running on. In Remote Path, enter the path to the root of
 
  33       your project on the machine the web server is running on.</p><div class="figure"><a name="phpeclipse.debuggingremote.debugconfigurationremotepathmap"></a><p class="title"><b>Figure 3. Specifying the Path Map from Local to Remote Machine</b></p><div class="figure-contents"><div class="screenshot"><div class="mediaobject"><img src="debugconfigurationremotepathmap.png" alt="Specifying the Path Map from Local to Remote Machine"></div></div></div></div><p><br class="figure-break">Once you have specified the proper pathmap, press the Debug
 
  34       button to begin the debugger.</p><p>You will notice that in contrast to when we were debugging
 
  35       locally, remote debugging will not automatically start your script. It
 
  36       will simply start the debugging and begin listening for connections on
 
  37       the debugging port. To begin our script, we open it up in a web
 
  38       browser.</p><div class="figure"><a name="phpeclipse.debuggingremote.remoteexecution"></a><p class="title"><b>Figure 4. Executing our Script in the Web Browser</b></p><div class="figure-contents"><div class="screenshot"><div class="mediaobject"><img src="remoteexecution.png" alt="Executing our Script in the Web Browser"></div></div></div></div><p><br class="figure-break"></p><p>This doesn't actually start debugging your script. There is no
 
  39       link at this point between your script and the Eclipse debugger. We have
 
  40       to somehow tell PHP to look for the Eclipse debugger for processing
 
  41       instructions. To do this, we have to add a variable to the request
 
  42       string. This variable is called XDEBUG_SESSION_START and its value
 
  43       should match the Ide Indentification String we specified earlier. In
 
  44       this case, our new URL will be
 
  45       http://127.0.0.1/myFirstProject/index.php?XDEBUG_SESSION_START=firstproject.</p><div class="figure"><a name="phpeclipse.debuggingremote.remotedebugxdebugvariable"></a><p class="title"><b>Figure 5. Adding the XDEBUG_SESSION_START onto the Query String</b></p><div class="figure-contents"><div class="screenshot"><div class="mediaobject"><img src="remotedebugxdebugvariable.png" alt="Adding the XDEBUG_SESSION_START onto the Query String"></div></div></div></div><p><br class="figure-break">Once you have added the variable to the URL, press enter to
 
  46       start debugging.</p><p>You can now resume the process of debugging as demonstrated in the
 
  47       local debugging tutorial. The process is the same, except that instead
 
  48       of the output being displayed in the console it is displayed in the
 
  49       browser where you loaded your script.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ar04.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ar04.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ar04s03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Debugging a Project On a Web Server Using PHPEclipse and
 
  50   XDebug </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Conclusion</td></tr></table></div></body></html>