You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VSCode PHP调试扩展无法连接DBGp代理服务器,如何解决?

环境信息

  • PHP版本:v8.1.18
  • Xdebug版本:3.2.0
  • Web服务器:远程192.168.10.10上的Homestead
  • DBGp代理服务器运行在本地Windows 10,启动命令:
./dbgpProxy.exe -i 127.0.0.1:9001 -s 0.0.0.0:9003
  • xdebug.ini配置:
xdebug.mode = debug
xdebug.client_port = 9003
xdebug.client_host = 192.168.10.1
xdebug.start_with_request = trigger
xdebug.trigger_value = ''
  • PHP调试launch.json配置:
{
    "name": "DBGp Proxy",
    "type": "php",
    "request": "launch",
    "pathMappings": {
        "/home/vagrant/laravel10": "D:\\workspace\\laravel10"
    },
    "proxy": {
        "enable": true,
        "host": "127.0.0.1",
        "port": 9001,
        "key": "vsc",
        "allowMultipleSessions": false
    }
}
  • DBGp代理服务器日志(VSCode调试失败时):
06:46:36.326 [info] [server] Start new server connection from 192.168.10.10:36512
06:46:36.327 [info] [proxy-client] [vsc] Could not find IDE connection for IDE Key 'vsc'
06:46:36.331 [warn] [server] Handler response error: Error reading response: Error reading length: EOF
06:46:36.332 [info] [server] Closing server connection from 192.168.10.10:36512
  • 使用PhpStorm时的正常日志:
07:03:13.986 [info] [server] Start new server connection from 192.168.10.10:37788
07:03:13.987 [info] [proxy-client] [PHPSTORM] Found connection for IDE Key 'PHPSTORM': 127.0.0.1:9000
07:03:13.991 [info] [proxy-client] [PHPSTORM] Connecting to 127.0.0.1:9000
07:03:13.994 [info] [proxy-client] [PHPSTORM] IDE connected
07:03:13.996 [info] [proxy-client] [PHPSTORM] Init forwarded, start pipe

问题

在VSCode中找不到类似Register IDE的功能,该如何将VSCode IDE客户端连接到DBGp代理服务器?

解决方法

  1. 确认PHP Debug插件状态
    确保VSCode安装了最新版的PHP Debug插件(Felix Becker开发版本),旧版本可能存在代理兼容性问题。

  2. 启动VSCode调试监听
    打开VSCode左侧调试面板(快捷键Ctrl+Shift+D),选择配置好的DBGp Proxy调试项,点击绿色启动按钮。此时VSCode会自动向DBGp代理的127.0.0.1:9001端口注册IDE Key为vsc的连接。

  3. 验证代理注册结果
    查看DBGp代理日志,若出现类似Found connection for IDE Key 'vsc': 127.0.0.1:xxxx的记录,说明VSCode已成功注册到代理。

  4. 触发远程调试请求
    由于Xdebug配置为start_with_request = trigger,需手动触发调试:

    • 在浏览器访问远程页面时,添加GET参数XDEBUG_SESSION_START=vsc(例:http://192.168.10.10/your-page?XDEBUG_SESSION_START=vsc);
    • 或设置名为XDEBUG_SESSION、值为vsc的Cookie。
  5. 排查异常情况

    • 若代理仍提示找不到IDE连接,检查本地Windows防火墙是否允许VSCode访问127.0.0.1:9001端口;
    • 确认launch.json中proxy.key的值(vsc)与触发调试时使用的IDE Key完全一致;
    • 若需跨设备连接,可将DBGp代理启动命令的-i参数改为0.0.0.0:9001,默认本地连接保持127.0.0.1:9001即可。

内容的提问来源于stack exchange,提问作者minus17

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 01:36:08