Getting xdebug to work with Netbeans using WampServer

I plan to use Netbeans IDE for my Moodle and WordPress PHP development. Netbeans is free, works on WAMP and is highly rated. Installation of WampServer is a bit tricky as you must absolutely follow the installation instructions to get it to work. Installation of Netbeans is straightforward.

My environment is as follows:

Windows 10 Pro 64bit WampServer 3.14, Apache 2.4.23, Php 7.0.10, Netbeans IDE 8.2

When I tried debugging with a breakpoint in my code, Netbeans would be waiting for Xdebug. It turns out that the php.ini settings related to Xdebug are crucial. I have mine as follows:

[xdebug]
zend_extension ="c:/wamp64/bin/php/php7.0.10/zend_ext/php_xdebug-2.6.1-7.0-vc14-x86_64.dll"
xdebug.remote_enable = 1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey="netbeans-xdebug"
xdebug.remote_autostart=1
xdebug.remote_connect_back=0
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = Off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="c:/wamp64/tmp"
xdebug.show_local_vars=0

Here are the things I went through in addition to above to make it work:

    1. Ensured that Netbeans->tools->options->php had port 9000 and session ID set to netbeans-xdebug
    2. Make sure that your WAMP server is running the same version of PHP as the version of xdebug file listed in zend_extension above, in php.ini. Also check that the path of zend_extention for the xdebug file is correct.
    3. I had xdebug.remote_host=127.0.0.1 but that didn’t work. Changing it to localhost made the connection. However, xdebug was not stopping at set breakpoints.
    4. I had to make xdebug.remote_autostart=1 in order for stopping at breakpoints to work.
    5. In php.ini I also set output_buffering = Off not sure if this is important.
Posted in debugging, php.