Reputation: 1
I have a Laravel project running inside Docker container on WSL2. Xdebug.log shows successful connection: Connected to debugging client: host.docker.internal:9003
. When I set a breakpoint and try to run the debugger though, nothing is being catched, and debugger never stops.
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "php-laravel debugger",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/var/www/html": "${workspaceFolder}/server"
},
},
]
}
docker-php-ext-xdebug.ini:
zend_extension=xdebug
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host=host.docker.internal
xdebug.discover_client_host=0
xdebug.client_port=9003
xdebug.start_upon_error=yes
xdebug.log=/tmp/xdebug.log
Relevant parts of docker-compose.yml:
server:
working_dir: /var/www/html
volumes:
- ./server:/var/www/html
ports:
- "8000:8000"
- "9003:9003"
environment:
XDEBUG_MODE: debug
XDEBUG_CLIENT_HOST: host.docker.internal
XDEBUG_CLIENT_PORT: 9003
extra_hosts:
- "host.docker.internal:host-gateway"
Edit:
As soon as I remove the ports: - "9003:9003"
line, XDebug is not able to connect anymore.
[1] [Config] INFO: Control socket set up succesfully: '@xdebug-ctrl.1'
[1] [Step Debug] INFO: Connecting to configured address/port: host.docker.internal:9003.
[1] [Step Debug] WARN: Creating socket for 'host.docker.internal:9003', poll success, but error: Operation in progress (29).
[1] [Step Debug] ERR: Could not connect to debugging client. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port).
Edit 2:
wsl hostname -I
in xdebug.client_host seemed to do the trick, connection is established. As soon as I rebuild the container and turn on debugger, it throws an error: Symfony\Component\Console\Exception\RuntimeException: The "--host" option does not exist.
, seemingly relating to CMD php artisan serve --host=0.0.0.0 --port=8000
line in the Dockerfile.
When I remove this line, error disappears, but I cannot interact with breakpoints whatsoever. It is as if VSCode is resolving exceptions in the background somehow, because all I can see is the logs that look like this: [24] [Step Debug] DEBUG: Breakpoint 240002 (type: line). [24] [Step Debug] DEBUG: D: Breakpoint 240002 (type: line) is already resolved.
Upvotes: 0
Views: 47