【问题标题】:PhpStorm + Xdebug: Connection established, no Debug window popup in PhpStormPhpStorm + Xdebug:连接已建立,PhpStorm 中没有弹出调试窗口
【发布时间】:2019-08-04 20:12:02
【问题描述】:

我正在努力让 PhpStorm 和 Xdebug 在特定的 Vagrant VM 上正常运行。

我如何才能有效地跟踪并解决此 VM 连接 PhpStorm 和 Xdebug 的问题?

虽然我可以看到 PhpStorm 和 Xdebug 在一定程度上进行了通信,但来自 Xdebug 的连接不会启动 PhpStorm 的调试窗口,并且无法使用 PhpStorm 的调试功能。

有问题的工具组合是:

  • 带有 Ubuntu 16-04 的 Vagrant VM
  • PHP 7.1 和 php-xdebug 2.7
  • PhpStorm 2018.2.1
  • Firefox Xdebug Helper 扩展
  • Drupal 8.6.10
  • 在第 16 行的 index.php 中插入断点。

我可以让这个 Vagrant VM 连接到 Atom 的 php-debug Xdebug 集成。我还可以让这个 PhpStorm 连接到其他 Vagrant 实例的 Xdebug!

来自相关服务器的 Xdebug 配置:

# xdebug.idekey = "PHPSTORM"
# xdebug.remote_connect_back = on
xdebug.remote_autostart = off
# xdebug.remote_connect_back = on
xdebug.remote_enable = on
xdebug.remote_handler=dbgp
xdebug.remote_host = 10.0.2.2 # IP of the host system
xdebug.remote_log="/tmp/xdebug.log"
xdebug.remote_mode=req
xdebug.remote_port=9000

使用此配置时,我在日志文件 /tmp/xdebug.log 中看到输出。

  • 将 Xdebug Helper 设置为“禁用”后,页面将在浏览器中加载。没有日志条目记录到 /tmp/xdebug.log
  • 将 PhpStorm 设置为“停止侦听 PHP 调试连接”后,页面将在浏览器中加载。没有日志条目记录到 /tmp/xdebug.log
  • 当 Xdebug Helper 设置为“调试”并且 PhpStorm 设置为“开始侦听 PHP 调试连接”时,页面会暂停,就好像断点已被识别一样。但是,PhpStorm 不会打开调试窗口,因此无法进行调试。以下记录到/tmp/xdebug.log
[8264] Log opened at 2019-03-14 01:39:02
[8264] I: Connecting to configured address/port: 10.0.2.2:9000.
[8264] I: Connected to client. :-)
[8264] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/html/drupal/web/index.php" language="PHP" xdebug:language_version="7.1.26-1+ubuntu16.04.1+deb.sury.org+1" protocol_version="1.0" appid="8264" idekey="PHPSTORM"><engine version="2.7.0"><![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>
[8264]
[8264] <- feature_set -i 1 -n show_hidden -v 1
[8264] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="show_hidden" success="1"></response>
[8264]
[8264] <- feature_set -i 2 -n max_depth -v 1
[8264] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_depth" success="1"></response>
[8264]
[8264] <- feature_set -i 3 -n max_children -v 100
[8264] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="3" feature="max_children" success="1"></response>
[8264]
[8264] <- feature_set -i 4 -n extended_properties -v 1
[8264] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="4" feature="extended_properties" success="1"></response>
[8264]
[8264] <- feature_set -i 5 -n notify_ok -v 1
[8264] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="5" feature="notify_ok" success="1"></response>
[8264]
[8264] <- stdout -i 6 -c 1
[8264] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stdout" transaction_id="6" success="1"></response>
[8264]
[8264] <- status -i 7
[8264] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="status" transaction_id="7" status="starting" reason="ok"></response>
[8264]
[8264] <- step_into -i 8
[8264] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="8" status="break" reason="ok"><xdebug:message filename="file:///var/www/html/drupal/web/index.php" lineno="14"></xdebug:message></response>
[8264]
[8264] <- eval -i 9 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
[8264] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="9"><property type="bool"><![CDATA[0]]></property></response>
[8264]
[8264] <- eval -i 10 -- aXNzZXQoJF9TRVJWRVJbJ1NFUlZFUl9OQU1FJ10p
[8264] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="10"><property type="bool"><![CDATA[1]]></property></response>
[8264]
[8264] <- eval -i 11 -- KHN0cmluZykoJF9TRVJWRVJbJ1NFUlZFUl9OQU1FJ10p
[8264] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="11"><property type="string" size="9" encoding="base64"><![CDATA[bG9jYWxob3N0]]></property></response>
[8264]
[8264] <- eval -i 12 -- KHN0cmluZykoJF9TRVJWRVJbJ1NFUlZFUl9QT1JUJ10p
[8264] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="12"><property type="string" size="4" encoding="base64"><![CDATA[ODAwMA==]]></property></response>
[8264]
[8264] <- eval -i 13 -- KHN0cmluZykoJF9TRVJWRVJbJ1JFUVVFU1RfVVJJJ10p
[8264] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="13"><property type="string" size="1" encoding="base64"><![CDATA[Lw==]]></property></response>
[8264]

如果我然后单击“停止侦听 PHP 调试连接”,我会立即看到以下记录到 /tmp/xdebug.log

[8264] <- run -i 14

紧随其后的是this logged output(对于这个问题来说太大了),页面和资源像以前一样加载。

如何有效地跟踪并解决此 VM 连接 PhpStorm 和 Xdebug 的问题?

PhpStorm > 语言 > PHP:

PhpStorm > 语言 > PHP > 调试:

【问题讨论】:

  • 您是否在 PhpStorm 中收到任何消息(例如,事件日志中的“调试查看已完成且未暂停”)?打开文件 |设置 |语言和框架 | PHP |服务器并删除您拥有的所有服务器配置(如果您可以的话)。然后再次开始调试 - PhpStorm 应该会提示您一个有关传入调试连接和配置路径映射选项的窗口 - 请检查那里的路径映射是否正确。
  • 我经历了几次路径映射过程,包括删除服务器配置,但都没有解决。我还找到了 PhpStorm 调试日志界面,并将该信息添加到问题中。谢谢!

标签: vagrant phpstorm xdebug


【解决方案1】:

您正在使用 PhpStorm 2018.2.x 和 Xdebug 2.7。

将 PhpStorm 升级到最新的稳定版 2018.3.x 或将 Xdebug 降级到 2.6.x

问题出在 Xdebug 协议中最近更改的 XML 命名空间中,从 Xdebug 2.7 开始(https 而不是 http)。它自 PhpStorm 2018.3.0 起已修复/受支持(请参阅 WI-43622)。

【讨论】:

  • 感谢,也感谢您通过问题更正了 PhpStorm 的大写。我很快就会试一试!
  • 这修复了它。非常感谢您抽出时间来回答这个问题。您能否提供参考我可能在 PhpStorm 网站上找到此信息的位置?我刚刚检查了What's new in PhpStorm(对于 2018.3,于 2018 年 11 月发布)的注释,并没有发现任何关于 Xdebug 支持变化的参考。
  • 非常感谢!我很高兴看到它现在可以在这个虚拟机上运行。
【解决方案2】:

您是否尝试取消注释 # xdebug.remote_connect_back = on

我们发现在 PhpStorm 和 XDEBUG 之间工作总是需要它。或者更好:

xdebug.remote_connect_back=1

我们在上面使用了我们的 Vagrant 解决方案 WPLib Box,我们专门构建它以使 XDEBUG 易于使用 PhpStorm。

我会在链接中向您展示它,但该 repo 是私有的。然而,我们最近在 Vagrant 中切换到 Docker,我们的 Docker 存储库是公共操作系统,这里是 our xdebug.ini file,用于我们的 PHP 7.2.6 Docker 容器。

希望这有助于解决您的问题。

【讨论】:

  • 谢谢!我已经尝试对此发表评论。它没有解决该行为。无论哪种方式,Xdebug 似乎都想连接到 10.0.2.2 上的主机系统,但 PhpStorm 报告连接来自 127.0.0.1。感谢您提供 xdebug.ini 链接,我会调查该链接和其他回复!
猜你喜欢
  • 2021-02-25
  • 2013-01-13
  • 2019-08-05
  • 1970-01-01
  • 2023-02-05
  • 2015-09-25
  • 2017-07-20
  • 1970-01-01
  • 2020-09-23
相关资源
最近更新 更多