0

Got a problem I need to get working. I'm having difficulty getting NetBeans 12.2 to connect to Xdebug. When I try to debug I get the dreaded "Waiting For Connection (netbeans-xdebug)" which never connects. I'm running the following:

  • PHP version 8.0.2
  • Apache 2.4.46
  • Xdebug 3.0.3

I've read some of the other threads e.g.

but they are for older versions of Xdebug and the solutions don't seem to work/commands are not the same. Having read the documentation and reading a solution in another threat my php.ini file has this at the end:

[xdebug]
zend_extension = C:\xampp\php\ext\php_xdebug-3.0.3-8.0-vs16-x86_64.dll
xdebug.client_port = 9003
xdebug.remote_handler = "dbgp"
xdebug.client_host = "localhost"
xdebug.mode=debug
xdebug.start_with_request=yes

When I click debug and run netstat I can see port 9003 is listening, but for some reason this just won't connect. I need this for work so I'm hoping someone can help a noob out? Best regards.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
tt460
  • 1
  • 1
  • 1) It's Xdebug that connects to IDE (NetBeans in your case) and NOT other way around. Check the docs please. 2) Enable Xdebug log, try to debug and see what it has to say. https://www.youtube.com/watch?v=IN6ihpJSFDw / https://learnxdebug.com/ 3) *"xdebug.remote_handler = "dbgp""* This is not needed -- it's from v2 and does nothing on v3 (does nothing even in 2.9.x) -- https://xdebug.org/docs/upgrade_guide – LazyOne Mar 06 '21 at 23:14
  • @LazyOne thank you. I checked the solutions for my error "[15920] [Step Debug] ERR: Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(" found here https://xdebug.org/docs/errors#DBG-E-TIMEOUT. The best functionality I can get is a connection when first opening the IDE, but then it appears to hang. The problem is described here by another user: https://stackoverflow.com/questions/66284710/netbeans-12-2-hanging-when-connecting-to-xdebug-3 The logs at the end of his post are the same as mine. Any advice? Best regards. – tt460 Mar 07 '21 at 09:15
  • 1) If it shows "Time-out connecting to debugging client" then it means that no-one listens on Xdebug port. Use `netstat -a -b -n` and show what app is listening on TCP 9003 port at that time. If none -- then well, that's the answer -- make sure that it listens at that moment. If it should be listening -- check firewall / any internet security anti-virus software etc. – LazyOne Mar 07 '21 at 10:48
  • 2) If the log shows that it connected but then no response ... then it must be some NetBeans issue. The protocol is the same in both Xdebug v2 and v3 so it should just work. Must be NetBeans itself then... I'm using PhpStorm and Xdebug v3 worked for me in 1 year old 2020.1 version (here is my proof for 2020.2 version: https://stackoverflow.com/a/64820427/783119; Xdebug v3 officially supported since 2020.3) – LazyOne Mar 07 '21 at 10:52
  • Netbeans is listening: TCP 0.0.0.0:9003 0.0.0.0:0 LISTENING [netbeans64.exe]. I think the firewall is setup correctly, perhaps it is a Netbeans issue. Unless someone answers that other thread I think this is as far as I can go! Thanks for your help @LazyOne, I may have to use another IDE. – tt460 Mar 07 '21 at 12:01

2 Answers2

0

I had the same problem, and these are the steps how i solved it:

  1. I reinstalled XAMPP, because I ruined my php.ini file due to configurate it too many times.

  2. Then I followed the steps from the Xdebug homepage. You can overread it fast if you don't focus.

    2.1 Download the .dll File and place it in your "Xampp/php extension directory" (C:\xampp\php\ext)

    2.2 Name it to: "php_xdebug.dll"

    2.3 Open the php.ini File (C:\xampp\php\php.ini)

    2.4 Implement following line: "zend_extension = xdebug"
    Note: I don't know if the order is important but for just in case put this Line under the following line: ";extension=shmop"

    2.5 Activate the step debugger with implementing following lines:
    "xdebug.mode=debug" (tells that
    "xdebug.start_with_request=default"
    Note: Here the same, put these lines under the following line: "extension=php_ftp.dll" (You can search for it, with the right editor)

Now you are finished with the php.ini file and can start with the Netbeans configuration.

  1. The debug configuration in Netbeans (Tools > Options > PHP > Debugging): Netbeans configuration

  2. The project properties in Netbeans (right-click on project > properties): Sources
    For Source and Project Folder I entered the same directory, in this case my Project.

  3. (right-click on project > properties > Run Configuration): Run Configuration

Links:
https://xdebug.org/docs/step_debug
https://xdebug.org/wizard

My PHP xdebug config: myphpinfo() - xdebug_config
Note: Step Debugger has to be enabled

PS: I tested this config. with PHP-8 and xdebug-3 and as "localhost" on Windows 10. It doesn't work for older versions!


I hope it solves your problem, i would be happy about a feedback!

0

There can be many reasons:

1.Missing php ini config

xdebug.idekey=netbeans-xdebug (or the value from netbeans settings - Session Id)

~ I think that form a specific version of netbeans 12.* this has been removed, but still you can give it a try

  1. try to configure the path mapping enter image description here

Map the xamp simulated server path to the real path on your computer To see your server path you could try to do a var_dump($_SERVER['DOCUMENT_ROOT'). It must be written as in linux format using '/' sepparator.

enter image description here

3.Optional If you are debugging with chrome check if the netbeans connector addon is enabled. Try to debug also with other browsers like firefox or edge to see if there is a difference.