xdebug配置
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
xdebug.remote_enable=1 #启用远程调试
xdebug.remote_autostart=1
xdebug.remote_port=9000 #端口
xdebug.remote_host=host.docker.internal #宿主机ip
remote_host是宿主机ip,因为是在宿主机下进行代码编写, remote_port=9000可能与fpm端口冲突,适当更改即可
vscode中的配置
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"pathMappings": {
"/code/shopCrm": "/Volumes/work/shopCrm"
}
}
]
}
port是xdebug配置里面的remote_port
pathMappings里面, "/code/shopCrm"是容器里面代码的路径, "/Volumes/work/shopCrm"是宿主机里面代码的路径