3

Goal
Debug with PHP Debug, Xdebug and VSCodium.

Problem

VSCode doesn't start debugging. When I click Start Debugging the blue line under the debugging control buttons appears and moves for a few seconds and then the control buttons disappear. Same when I press the green "Run" button

phpdebugvscode1

Also on the left side, where "variables", "watch" and "stack" are shown nothing appears.

Description
I have no experience with the VSCodium debugging options. I used a couple of tutorials (1, 2, 3, videos and tried certainly the proposal from the VSCode PHP Debug extension site (which I use). I'm using Codium (VSCode without MS) on a Linux Mint 20 machine. PHP 7.4 and Xdebug are installed via Linux Synaptic Package Manager. Of course the Xdebug helper in Firefox is enabled, breakpoints are set and I tried it in different projects. I tried a few things in the php.ini. That's how it looks at the moment:

[XDebug]
xdebug.remote_enable = 1
; xdebug.remote_autostart = 1
; xdebug.remote_connect_back = 1

Xdebug itself is loaded via the /etc/php/7.4/cli/conf.d/20-xdebug.ini and in PhpStorm it works like expected but not in VSCodium.

That's the standard launch.json, which is saved in the .vscode folder in the project root:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Listen for XDebug",
      "type": "php",
      "request": "launch",
      "port": 9000,
      "log": true
    },
    {
      "name": "Launch currently open script",
      "type": "php",
      "request": "launch",
      "program": "${file}",
      "cwd": "${fileDirname}",
      "port": 9000
    }
  ]
}

Here is a part of my phpinfo() output:

phpinfo1

And the xdebug part:

enter image description here

enter image description here

And here the xdebug log when i try it with VSCodium:

[5625] Log opened at 2020-10-04 10:05:20
[5625] I: Connecting to configured address/port: localhost:9000.
[5625] W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (29).
[5625] E: Could not connect to client. :-(
[5625] Log closed at 2020-10-04 10:05:20

My guess is, that there is a basic VSCodium debugging thing, I didn't enabled or so. But I don't know, what it could be. Maybe somebody has an idea?

4
  • 1) Enable, collect and share Xdebug log for such unsuccessful debug session. It will tell where it tries to connect to and what the response is etc. 2) Post whole Xdebug section from phpinfo() output captured in the same way you are trying to debug (as it may be different for Web page debug and CLI -- it's very common to have different php.ini configs used for CLI and web server on Linux and Mac). Commented Oct 2, 2020 at 10:53
  • So Xdebug tries to connect to localhost:9000 (port TCP 9000 on the same PC) .. but something prevents from connecting. Is VSCode already listening on that port? After you click on Debug in VSCode, check with netstat or similar tool what program is listening on TCP 9000. It has to be VSCode (as it's Xdebug that connects to IDE and not other way around). I'm not using VSCode myself (PhpStorm user) so cannot say what you may be missing from VSCode side of things. Commented Oct 4, 2020 at 10:25
  • No, VSCode doesnt listen to any port. As i wrote, with PhpStorm it works. The problem is, when i click in VSCode on Debug it doesnt start really. Commented Oct 4, 2020 at 20:24
  • So you need to do something about it: make VSCode start listening somehow. As I have said, I have not used VSCode so cannot say what you need to do except try another tutorial / ideally a video that shows such part. Logically thinking, you need to hit that "Listen for XDebug" and it will be listening on TCP 9000 port. If it does not -- maybe some another process already listens there etc? What about firewall? That's all I may say for now. Commented Oct 4, 2020 at 20:42

1 Answer 1

4

Finally found the solution. Its a Codium specific bug. At VSCode it works. Found the solution here: https://github.com/VSCodium/vscodium/issues/466

  1. make sure you don't have PHP Debug extension installed;

  2. go to https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug and download vsix file using "Resources" → "Download Extension";

  3. in VSCodium go to "Extensions" sidebar and then click three dots icon near to "Extensions" title;

  4. choose "Install from VSIX…" and select downloaded file.

@LazyOne thanks for your help again :)

Edit:

If you are updated to Xdebug 3.* you have to modify the xdebug section in the php.ini:

Add this:

xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9000

You could drop the last line if you change instead the port to 9003 in your launch.json.

See also this GitHub Issue

Sign up to request clarification or add additional context in comments.

2 Comments

Spend several hours trying to figure it out, thinking it's a problem with the Docker setup. Turns out it's a bug. Thank you so much.
On Linux it is also important to check your firewall. If ufw is enabled it could block Xdebug too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.