Configuring NetBeans 8 with XDebug Connection on WAMP

Configuring and connecting NetBeans with XDebug to run and debug local PHP projects and scripts is very simple.

These instructions will work for any WAMP, such as Xampp or WampServer, but are specific to WampDeveloper Pro (as it already provides everything needed).

Load and Configure PHP’s XDebug Extension

Open PHP’s configuration file: php.ini.

Find and un-comment the XDebug section that already exists near the end of php.ini, by removing the “;” from each settings line. Save file. Restart Apache.

[XDebug]
; Note that profiler is enabled separately.
zend_extension="C:\WampDeveloper\Components\Php\ext\php_xdebug.dll"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_autostart=0
xdebug.remote_connect_back=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.profiler_output_name=cachegrind.out.%s.%t
xdebug.profiler_output_dir="C:/WampDeveloper/Temp/xdebug"
xdebug.trace_output_dir="C:/WampDeveloper/Temp/xdebug"

The provided XDebug settings will work with the NetBeans IDE out-of-the-box. The configuration uses as many default values as it can, and nothing needs to be changed as long as NetBeans is on the same system WAMP is on.

Create NetBeans Project

We will set up a project that uses the www.example.com website, and it’s contents (the index.php file).

New project:

PHP Application with Existing Sources

Sources Folder:

C:\WampDeveloper\Websites\www.example.com\webroot\

* Changed from the pre-filled default to update to the website’s DocumentRoot folder.

Project Name:

TestProject

PHP Version:

PHP 5.6

Runs As:

Local Web Site (running on local web server)

Project URL:

http://www.example.com/

* Changed from the pre-filled default of “localhost” to website’s Primary Domain Name. And removed the “/webroot” part, as it’s not a URL, it’s the website’s DocumentRoot folder.

Index File:

index.php

Finish Project.

Start Debugging

In NetBeans, open the index.php file, and set a debug break-point on any PHP line.

* Use “<?php” instead of “<?” for your PHP code unless you’ve enabled the NetBeans option to use short-tags in the project.

Make sure Apache is running, and click the IDE’s “Debug Project” (not “Run Project”) icon.

It will open the system’s default Browser to URL:
http://www.example.com/index.php?XDEBUG_SESSION_START=netbeans-xdebug

That “XDEBUG_SESSION_START” part tells PHP to start XDEBUG for that request, and it will provide NetBeans the debug data by sending it to the specified IP and Port (in php.ini) / which is the address NetBean’s XDebug client is listening on.

You should be able to now step through the PHP code using the NetBeans IDE!

Issues

If for some reason your PHP code can’t handle the query string, you can enable “xdebug.remote_autostart=1” (php.ini) to auto start debugging for all requests. But this will slow everything down further, and also generate much more data.

Once done, make sure to stop the Debugging process so everything get’s cleared out.

If there are any issues with Apache and PHP request timeouts, these can always be increased.

And if any odd issues start happening with either the Browser or the XDebug sessions:

  • Make sure to stop NetBeans Debugging.
  • Go into the Browser’s settings, and clear out the entire History, Temp files, and Cache, then close it.
  • Restart Apache.

Also, it’s best to not use IE as the default Browser for NetBeans, but to change to using the “Embedded WebKit Browser”, via the Project’s properties.

One thought on “Configuring NetBeans 8 with XDebug Connection on WAMP”

  1. The following xdebug configuration was for netbeans using wamp server (localhost). Look for the file: WAMP -> PHP -> php.ini
    Add the following:
    =========================================================
    zend_extension =”c:/wamp64/bin/php/php5.6.31/zend_ext/php_xdebug-2.5.5-5.6-vc11-x86_64.dll”
    xdebug.default_enable = 1
    xdebug.idekey = “netbeans-xdebug”
    xdebug.max_nesting_level = 256
    xdebug.profiler_append = 0
    xdebug.profiler_enable = 0
    xdebug.profiler_enable_trigger = 0
    xdebug.profiler_output_dir = “C:/wamp64/tmp”
    xdebug.profiler_output_name = “cachegrind.out.%t-%s”
    xdebug.remote_enable = 1
    xdebug.remote_autostart = 1
    xdebug.remote_connect_back = 0
    xdebug.remote_host = “127.0.0.1”
    xdebug.remote_connect_back = On
    xdebug.remote_port = 9000
    xdebug.remote_handler = “dbgp”
    xdebug.remote_mode = req
    xdebug.remote_log = “C:\wamp64\tmp\xdebug_remot.log”
    xdebug.show_local_vars = 9
    xdebug.trace_output_dir = “C:\wamp64\tmp”
    ========================================================
    Remark:

    in WAMP:
    your projet needs to be on C:\wamp64\www\yourfolder

    On netbeans:
    Projet folder: C:\wamp64\www\yourfolder
    Source folder: C:\wamp64\www\yourfolder

    When creating the projet on netbeans don’t check: put netbeans mtadata into a separate directory. Both paths need to be the same for the projet and the source…

    Browser extentions
    chrome extention: Xdebug helper fixed by Buu
    firefox extention: xdebug helper

    * Look for the options of those extentions choose netbeans as IDE

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>