Issue
PROBLEM: I am currently unable to debug php within NetBeans 8.2 RC on Windows 10. NetBeans shows "Waiting for Connection" in lower right and never connects.
Most of the tutorials I found were from several years ago:
- href="https://www.codewall.co.uk/debug-php-with-xdebug-on-netbeans/" rel="nofollow noreferrer">Codewall article //2018...newest?
- Michael Milette's Tutorial //seemed thorough, but from 2014
- NetBeans site // references php 5...yikes!
- Rob Prouse's Tutorial //2010
Note some of these have differing instructions for what should go in php.ini
Xdebug stuff
phpinfo()
lists Xdebug as running version 2.9.4 with IDE Key: netbeans-xdebug so at least it's recognized.
relevant php.ini [XDebug] info:
...
output_buffering=off
...
[XDebug]
zend_extension = "c:\xampp\php\ext\php_xdebug-2.9.4-7.4-vc15-x86_64.dll"
xdebug.idekey = netbeans-xdebug
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
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_autostart = 0
xdebug.remote_connect_back = 0
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_log="c:\xampp\tmp\xdebug.txt"
xdebug.remote_port = 9000
xdebug.show_local_vars = 9
xdebug.trace_output_dir = "c:\xampp\tmp"
; 3600 (1 hour), 36000 = 10h
xdebug.remote_cookie_expire_time = 36000
'netstat -an' results while netbeans is waiting for connection Note the two-way connection between 57418 and 9000
xdebug error log
[10112] Log opened at 2020-07-27 15:33:34
[10112] I: Connecting to configured address/port: 127.0.0.1:9000.
[10112] E: Time-out connecting to client (Waited: 200 ms). :-(
[10112] Log closed at 2020-07-27 15:33:34
[10112] Log opened at 2020-07-27 15:33:47
[10112] I: Connecting to configured address/port: 127.0.0.1:9000.
[10112] I: Connected to client. :-)
[10112] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/xampp/apps/wordpress/htdocs/index.php" language="PHP" xdebug:language_version="7.4.0" protocol_version="1.0" appid="10112" idekey="netbeans-xdebug"><engine version="2.9.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>
[10112] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
[10112] Log closed at 2020-07-27 15:33:51
[10112] Log opened at 2020-07-27 15:33:52
[10112] I: Connecting to configured address/port: 127.0.0.1:9000.
[10112] E: Time-out connecting to client (Waited: 200 ms). :-(
[10112] Log closed at 2020-07-27 15:33:52
[10112] Log opened at 2020-07-27 15:34:05
[10112] I: Connecting to configured address/port: 127.0.0.1:9000.
[10112] I: Connected to client. :-)
[10112] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/xampp/apps/wordpress/htdocs/index.php" language="PHP" xdebug:language_version="7.4.0" protocol_version="1.0" appid="10112" idekey="netbeans-xdebug"><engine version="2.9.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>
php_xdebug-2.9.4-7.4-vc15-x86_64.dll was the dll recommended by xdebug.org/wizard and is at the expected file location.
NetBeans Configuration
Since I'm attempting to debug a WordPress plugin, I have the entire 'wordpress' directory as my project within NetBeans.
Sources:
Hmm...PHP Version is set to 7.0, and I'm trying to use 7.4...but it says "PHP version is used only for hints". Is this just a simple case of 'NetBeans 8.2 RC doesn't support PHP 7.4'?
Run Configuration:
Any help is appreciated. Thanks in advance. EDIT: Include xdebug info from phpinfo(), netstat results, and xdebug dump.
Potentially helpful After changing the behavior to launch the browser again, I noticed that the project wasn't loading with the "?XDEBUG_SESSION_START=netbeans-xdebug" flag until after I hit stop. This seemed weird to me, but I tried starting the debugger, hitting stop (to launch the website with the flag), and then attaching the debugger. It didn't work (NetBeans spins on 'waiting for connection' and Chrome spins on 'waiting for localhost'). Chrome loads eventually, but the second I try to start navigating to the part of the site to run the php code I'm trying to debug, it goes back to spinning on 'waiting for localhost' with the following xdebug dump (it never navigates away from the home page):
[22340] Log opened at 2020-07-27 15:49:37
[22340] I: Connecting to configured address/port: 127.0.0.1:9000.
[22340] I: Connected to client. :-)
[22340] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/xampp/apps/wordpress/htdocs/index.php" language="PHP" xdebug:language_version="7.4.0" protocol_version="1.0" appid="22340" idekey="netbeans-xdebug"><engine version="2.9.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>
Solution
For the poor soul trying to get NetBeans working, the answer is...don't use NetBeans. I understand this is a terrible answer, but after 5 hours trying to get it working compared to the 20 minutes getting VSCode working NetBeans just doesn't make sense (unless you have some other reason for using it).
To get VSCode working, I mainly followed this tutorial: https://stackify.com/php-debugging-guide/
Combined with the following php.ini settings:
...
output_buffering=off
...
[XDebug]
zend_extension = "c:\xampp\php\ext\php_xdebug-2.9.4-7.4-vc15-x86_64.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
Note how fewer settings I actually needed!
Answered By - sacredfaith
Answer Checked By - Marie Seifert (JavaFixing Admin)