I am trying to debug a Laravel application using docker, X-debug2.7.2, centos, and php7.3.7 However, the breakpoint is not respected. The log is updated with the following message.
[41] Log opened at 2019-10-02 21:09:33
[41] I: Connecting to configured address/port: docker.for.win.localhost:9000.
[41] I: Connected to client. :-)
[41] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/public/index.php" language="PHP" xdebug:language_version="7.3.6" protocol_version="1.0" appid="41"><engine version="2.7.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2019 by Derick Rethans]]></copyright></init>
[41]
[41] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
[41]
[41] Log closed at 2019-10-02 21:09:34
XDebug Configuration
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 0
xdebug.remote_enable = 1
xdebug.remote_host = docker.for.win.localhost
xdebug.remote_log = "/tmp/xdebug.log"
xdebug.remote_port = 9000
Vscode Configuration
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"pathMappings": {
"/var/www": "${workspaceRoot}"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000,
"pathMappings": {
"/var/www": "${workspaceRoot}"
}
}
UPDATE
After many attempts, I ‘ve set the remote_host at x-debug configuration to the IP of my local machine and it worked.
For those who believe that the alias host.docker.internal would work, it didn’t. So what I did was to set a fictional name for the remote_host key and I configure it in the docker-compose as an extra host with the local IP.
I didn’t consider this a good solution, because everyone using this configuration file will need to change it locally. So I would like to know if you guys have a better solution for this case.
2
Answers
This may be a funny question, but are you using a plugin for your browser to communicate with xdebug? Like ‘debugging’ (firefix) or ‘Xdebug-helper’ (chrome)
This likely indicates that something else is listening on port 9000. Are you using PHP-FPM? If so, please either change the PHP-FPM port to something else, or the Xdebug one. Your IDE has a setting for it (
"port": 9000
, twice), and in php.ini you can usexdebug.remote_port=9001
(as an example). Please do also restart your web server if you make thatphp.ini
(or90-xdebug.ini
, or whatever it is called) change.