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.

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.