Why You Do Not Have to Specify Hosts in VSCode with XDebug?

Asked 2 years ago, Updated 2 years ago, 107 views

Thank you for your help.
Apache and Xdebug are running on CentOS booted from Vagrant, and they are being debugged using Visual Studio Code and PHP Debug plug-in to attach breakpoints.
Now, I have a question, but the configuration file on VSCode does not have items to set up such as remote hostnames.

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Remote Debug",
      "type": "php",
      "request": "launch",
      "serverSourceRoot": "/var/www/html",
      "localSourceRoot": "${workspaceRoot}",
      "port"—9001
    }
  ]
}

It works with this kind of setting.
However, I don't know which port 9001 I should go to with this alone.
If you have decided to go to localhost 9001, there will be port forwarding settings on the host side and the guest side, but I can't find such an article anywhere.
Does this mean that Xdebug itself has something like that?

php vagrant vscode

2022-09-30 21:26

1 Answers

It's a self-answer.

When Xdebug is enabled, after the server receives an http request (xdebug.ini), it tries to communicate with a protocol called DBGP for debugging.
The setting for that destination is xdebug.remote_host.Also, xdebug.remote_connect_back is configured to communicate to the place where the http request was made.
Therefore, I understand that the host information is naturally unnecessary for those who attach breakpoints to the code, but on the other hand, it is written on the server side and communication starts on the server side.

Please take care of me if there is anything strange.

By the way, I asked this question because I wanted to debug the processing of Webhook, which was originally directed locally on ngrok.
I turned on the xdebug.remote_connect_back setting, so I couldn't understand because DBGP didn't connect to the local environment.


2022-09-30 21:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.