问题
I cannot get the VS Code extension "Php debug" to stop on any breakpoints. I am running the php project (that I want to debug) from Docker on my Ubuntu laptop. Any advice greatly appreciated.
My set up:
- PHP version on Docker: 7.1
- XDebug version on Docker: 2.6.1
- PHP Debug version in VS Code (on my laptop): 1.12.6
My VS Code launch.json file is:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"log": true,
"pathMappings": {
"/var/www/html": "/home/chris/my-test-debugging-project"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
my /usr/local/etc/php/conf.d/xdebug.ini config is:
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_host=172.17.0.2
xdebug.remote_log=/var/www/html/xdebug.log
xdebug.remote_connect_back=0
xdebug.remote_port=9000
XDebug logfile (from setting xdebug.remote_log in php.ini):
Log opened at 2018-10-14 05:47:16
I: Connecting to configured address/port: 172.17.0.2:9000.
W: Creating socket for '172.17.0.2:9000', poll success, but error: Operation now in progress (29).
E: Could not connect to client. :-(
Log closed at 2018-10-
14 05:47:16
The PHP Debug log output (from setting "log": true in launch.json):
<- launchResponse
Response {
seq: 0,
type: 'response',
request_seq: 2,
command: 'launch',
success: true }
回答1:
Try setting xdebug.remote_connect_back=1
and let me know if that works.
If it does we should probably close this question as a duplicate of the question that I previously answered.
回答2:
As i know 9000 is the php-fpm port that use by default. So if you use the same port for the xdebug.remote_port=9000
It will not work. You can check that by nginx conf as an example mine cat /etc/nginx/conf.d/site.conf
you can check the line fastcgi_pass 127.0.0.1:9000;
or run lsof -n -iTCP:9000 | grep LISTEN
will show if its utilized. I would suggest you to
- change it to something not used ex: 10000
xdebug.remote_host
might wrong, login to the container and try to ping the172.17.0.2
if it is not working yourxdebug.remote_host
is wrong. Find the ip of the host machine replace it with the current172.17.0.2
回答3:
I run a local linux web server on a VM. And using samba i mapped on a Windows device letter my share.I followed all the suggestions but the breakpoints where not working as supposed. I could only debug adding "stopOnEntry": true" to launch.json, but not on personally added breakpoints, they were all ignored. My problem was the path where my app was running, i fixed like this:
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9900,
"log": true,
"stopOnEntry": false,
"pathMappings": {
"/var/www/html/booking" : "z:",
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9900
}
]
}
This obiouvsly is my linux path -> "/var/www/html/booking" And this is drive mapped letter -> "z:"
来源:https://stackoverflow.com/questions/52834240/visual-studio-code-php-debug-does-not-stop-on-breakpoints-for-docker-project