V
V
VicTHOR2021-06-21 14:17:15
PHP
VicTHOR, 2021-06-21 14:17:15

How to set up xdebug in vscode if the project is inside a virtual machine and is raised via docker there?

VSCode is installed on Windows, via Remote-SSH there is a connection to the server, which is raised in VirtualBox.
Docker is installed on the server and the project will rise through docker, in the ini file there are the following xdebug settings:

[xdebug]
zend_extension=xdebug.so
xdebug.profiler_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=host.docker.internal
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_connect_back=1

Docker forwards the project from the conditional path /srv/projects/wwwin the virtual machine to the path /var/www/htmlin the container through the volume.
I'm trying the following debugger settings in vscode:
{
    "name": "Listen for Xdebug",
    "type": "php",
    "request": "launch",
    "port": 9000,
    "log": true,
    "externalConsole": false,
    "pathMappings": {
        "/var/www/html": "${workspaceRoot}",
    },
    "ignore": [
        "**/vendor/**/*.php"
    ],
},

${workspaceRoot}Tried absolute path instead /srv/projects/www, doesn't help. Yes, and the workspace must be correct, I connect to the project folder.

The debugger turns on, but does not stop on a breakpoint.
Tried to play with the settings in different ways, nothing happened. I really don't know how xdebug works and what I'm doing wrong.
How to solve this problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question