Debug PHP Web App with Xdebug, Xdebug Helper, Eclipse Indigo with PDT extension, XAMPP, php5.4.7 on Windows 7

1. Download and install Eclipse IDE(Indigo or later versions of Eclipse IDE), XAMPP.
2. Install PDT on Eclipse. Refer http://wiki.eclipse.org/PDT/Installation for instructions.
3. Install BitNami WordPress or Drupal or Joomla, or all of them on XAMP. Those can be installed easily on the XAMPP admin page, Applicaions.
4. Download the xdebug dll file. This wizard will tell you the version of xdebug file you need http://xdebug.org/wizard.php
5. Configure the php.ini file to use the xdebug dll downloaded from step 4.

    a. Assume the XAMPP home is C:\xampp, put the xdebug dll file to C:\xampp\php\ext\php_xdebug-2.2.3-5.4-vc9.dll
    b. Open C:\xampp\php\php.ini, and put the following at the end of the file. If those are already there, modify them to look like the below.

    		[XDebug]
    		zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.3-5.4-vc9.dll"
    		xdebug.profiler_append = 0
    		xdebug.profiler_enable = 1
    		xdebug.profiler_enable_trigger = 0
    		xdebug.profiler_output_dir = "C:\xampp\tmp"
    		xdebug.profiler_output_name = "cachegrind.out.%t-%s"
    		xdebug.remote_enable = 1
    		xdebug.remote_port=9002
    		xdebug.remote_handler = "dbgp"
    		xdebug.remote_host = "127.0.0.1"
    		xdebug.remote_mode=req
    		xdebug.trace_output_dir = "C:\xampp\tmp"
    	

    c. Restart Apache server on XAMPP’s admin panel.
    d. Go to XAMPP admin page, and then go to phpinfo(). Search for xdebug on the phpinfo page to make sure xdebug is installed. If you can see the above configuration on the phpinfo page, that means the xdebug was installed successfully.

6. Configure Eclipse PDT to use XDebug.

    a. Create a new PHP project from a existing directory, for example, the Drupal installation directory, C:\xampp\apps\drupal\htdocs
    b. Window->Preference->PHP->Debug, make the settings like this

      PHP Debugger: XDebug
      Server Default PHP Web Server
      PHP Executable: PHP 5.4.7

    c. Window->Preference->PHP->Debug->Installed Debuggers->Select XDebug and click Configure, make the below settings
    Debug Port 9002
    Accept remote session (JIT) localhost
    d. Window->Preference->PHP->PHP Executables, this should have configured already if when setting php executables from step b.
    e. Window->Preference->PHP->PHP Interpreter->Select PHP 5.4
    f. Window->Preference->PHP->PHP Servers->Click New, and put the below settings

      Name can be anything, Default PHP Web Server
      Base URL: http://localhost
      Local Web Root: C:\xampp\htdocs

7. Install XDebug Helper on Chrome. Once this is installed, a bug will show up in the address bar. The color will be green when enabled, grey when disabled.
8. Open the Drupal index.php in Eclipse, put a breakpoint next to a line of code, right click the file on the explorer, Debug As PHP Web Application.
9. Make sure the bug is green in the address bar. Load the Drupal home page on Chrome, with BitNami Drupal installed, the link should be http://localhost/drupal/, and the page will not be loaded fully, it will stop at the breakpoint you put in Eclipse.Now we can start debugging in the Eclipse Debug mode.

10. If there are any issues, make sure the below are sound.

    a. The ip address for xdebug.remote_host in the php.ini file is 127.0.0.1
    b. The Accept remote session (JIT) in Eclipse setting is localhost
    c. The xdebug.remote_port is matched up the Debug port in Eclipse, 9002
    d. The bug icon of the XDebug Helper in the Chrome address bar is enabled with green color
    e. Make sure the localhost is pointing to 127.0.0.1
    f. Try not to use any port numbers other than 80 for the web application, the default port number for Apache loacalhost
    g. Last advice, try to get the XDebug working with the simplest web application first, it could as simple as a php hello world page first.

Search within Codexpedia

Custom Search

Search the entire web

Custom Search