1

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:

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

xdebug info from phpinfo() xdebug_1 xdebug_2 xdebug_3

'netstat -an' results while netbeans is waiting for connection enter image description here 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:

Project Properties

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:

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>
sacredfaith
  • 850
  • 1
  • 8
  • 22
  • 1) *"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'?"* I'm not NetBeans user .. but that looks like PHP Language Level and not actual PHP interpreter/executable. Language level is used by editor/inspections to tell that you are not using features from newer PHP version (so your code will work on that PHP version and not fail) – LazyOne Jul 27 '20 at 11:30
  • 2) *"NetBeans shows "Waiting for Connection" in lower right and never connects."* Just in case: it's Xdebug that connects to IDE and NOT other way around. so you need to check: 2.1) Actual/live Xdebug settings -- post whole Xdebug section of the `phpinfo()` output 2.2) Maybe NetBeans is unable to listen on TCP 9000 port? Check with `netstat` or alike to see what process uses it when IDE is listening for incoming connections. – LazyOne Jul 27 '20 at 11:34
  • 2.3) Collect and share Xdebug log for such unsuccessful debug session (try not to mix multiple sessions in one: empty log in between) -- it will tell if it tries to connect and what the outcome is. – LazyOne Jul 27 '20 at 11:34
  • Edited to include xdebug section of phpinfo, netstat results, and xdebug error dump from a single session. I should also note that I tried changing the behavior to launch the browser, but it doesn't launch with the "?XDEBUG_SESSION_START=netbeans-xdebug" flag until AFTER I hit stop...seems odd. At that point (and when the xdebug dump was generated) the browser is spinning on 'waiting for localhost' while netbeans is spinning on 'waiting for connection'. – sacredfaith Jul 27 '20 at 15:39
  • As an aside, I noticed the timestamp for the xdebug dump reads 'Log opened at 2020-07-27 15:49:37"...but I'm in Bangkok Thailand and it's 22:49 here, not 15:49. Could THAT be screwing everything up? Note that I did set the timezome to Asia/Bangkok in my php.ini file. Perhaps I need to set it elsewhere as well? – sacredfaith Jul 27 '20 at 15:55
  • 1) Time: ignore -- it might be in UTC timezone; it should not be causing any issues here. 2) Log: it shows successful sessions and failed ones. It could be because you have screw up NetBeans configuration somewhere (over configuration). The successful session has no much info there, just few seconds long and nothing recorded except "continue executing " kind of response. – LazyOne Jul 27 '20 at 16:43
  • https://www.codewall.co.uk/wp-content/uploads/2018/09/netbeans-php-debugging-configuration.jpg -- this is debugger port. Your screenshot (https://i.stack.imgur.com/QVmjn.png) is for some proxy (GBDp Proxy I guess) -- it could be an issue/misconfiguration here (you need to have an actual proxy software installed on a different port etc etc). – LazyOne Jul 27 '20 at 16:45
  • Since I'm not NetBeans user I cannot say exact steps/what to check (as I'm not familiar with their interface that well). I suggest this: try to get rid of your NetBeans settings and start from scratch (you have have right defaults). Then just follow ONE tutorial and do not do any extra that is not mentioned there. – LazyOne Jul 27 '20 at 16:46
  • I don't even know how to answer this, but I did some more searching, saw that quite a few people use vscode with xdebug - took your advice and followed a shiny new tutorial (fastest way to get rid of NetBeans was to simply not use NetBeans, but a different IDE entirely). Anyways, I was debugging in less then 20 minutes using this: https://stackify.com/php-debugging-guide/ Compared to the 5+ hours behind this question. – sacredfaith Jul 28 '20 at 08:43

1 Answers1

-2

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!

sacredfaith
  • 850
  • 1
  • 8
  • 22
  • Note: Mods, if answering this was the wrong move then feel free to edit/delete/ etc. as appropriate. I understand that answering "How do I solve X problem?" with "Don't ask that, ask this other question instead" doesn't make for a good answer. I'm just not sure how to best preserve what I tried as well as what I landed on without posting it as the answer. Thanks. – sacredfaith Jul 28 '20 at 08:50