我正在尝试让 xdebug 工作,但目前我无法判断我是否缺少 xdebug 的一些基本组件或者它是 xdebug 本身。我访问过许多教程和指南,但运气不佳。
所以我设置我的 xdebug 配置如下:
zend_extension=xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_log = /tmp/xdebug.log
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
#xdebug.remote_host = 192.168.56.1
#xdebug.remote_port = 9000
#xdebug.idekey = xdebug-atom
xdebug.var_display_max_depth = 8
我正在尝试 PhpStorm 和 VSCode。在 PhpStorm 中,当我使用他们的“零配置调试”时,它开始监听,但直接点击页面或使用 POSTMAN 没有任何影响。我偶尔会在日志中收到以下错误:
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to 192.168.56.1:9000.
E: Time-out connecting to client. :-(
当我在 PhpStorm 中设置服务器时,它似乎激活并保持连接,但同样,断点上没有中断。在 VSCode 中,它似乎也激活并监听,但什么也没有,而且我在 VSCode 尝试的日志中没有看到任何内容。
当我在 POSTMAN 中设置 XDEBUG_SESSION
cookie 时,我确实注意到它损坏了,但是从这么多教程来看,似乎表明这对于 remote_connect_back 来说不是必需的?如您所见,我已将 idekey 注释掉了。我错了吗?无论如何,你确实需要 cookie?
我怎样才能找出问题所在?我已经浏览了 xdebug 文档、与 Xdebug 相关的 PhpStorm 文档,并且不知道有多少博客文章。
最佳答案
I: Remote address found, connecting to 192.168.56.1:9000. E: Time-out connecting to client. :-(
这通常表明端口 9000 上没有任何监听,或者存在防火墙阻止 Xdebug 连接到 IDE。
When I set the XDEBUG_SESSION cookie in POSTMAN, I do notice it breaks, but from so many tutorials, it seem to indicate this isn't necessary with remote_connect_back? As you can see, I have the idekey commented out. Am I wrong and you do need the cookie, regardless?
如果您只是自己调试自己的应用程序,那么“idekey”是无关紧要的。它仅与 DBGp 代理一起发挥作用(这超出了本问题的范围)。仅在 CLI 上,Xdebug 关心通过 export XDEBUG_CONFIG="idekey=yourname"
设置 idekey。但由于您不在这里进行 CLI 调试,因此它的值并不重要。
xdebug.remote_connect_back
仅处理选择要连接的 IP,它对 Xdebug 是否尝试连接没有影响。
要连接,需要有XDEBUG_SESSION
cookie(或XDEBUG_SESSION_START
GET参数),或,可以设置xdebug.remote_autostart ,在这种情况下,无论 cookie 如何,Xdebug 都会在每次请求时尝试连接到 IDE。
另请注意,该问题的标题具有误导性。 IDE 将不会与 Xdebug 建立连接,是 Xdebug 与 IDE 建立连接。
关于php - 没有 IDEKEY 无法建立 Xdebug 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48189776/