phpstorm - Xdebug 与 PhpStorm 在 CLI 中工作正常,而不是在浏览器中工作

标签 phpstorm xdebug

我正在尝试使用 Xdebug 和 PhpStorm 进行调试。我过去已经设置过好几次了,没有太大问题。但这一次事情进展并不顺利。

我当前在 php.ini 中的配置如下:

zend_extension = "c:\xampp2\php\ext\php_xdebug.dll"

xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_host=127.0.0.1
xdebug.remote_cookie_expire_time=3600
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.idekey=PHPSTORM
xdebug.remote_log="c:\xampp2\tmp\xdebug.txt"

xdebug.remote_autostart=1

添加 xdebug.remote_autostart 确保每当从 CLI 运行脚本时都会建立连接。但通过 Apache 调用脚本时它仍然不起作用。

我检查了 Xdebug 日志,没有发现任何异常情况:https://pastebin.com/4rK8pJqt

最明显的原因是 CLI 和 Apache 有单独的 php.ini 文件,但事实并非如此。我只有一个 php.ini 文件,并且我已经验证 Xdebug 设置在浏览器的 phpinfo 中显示得很好。请参阅下面的屏幕截图。

是否有任何特定设置可能导致 Xdebug 无法连接到 PHPStorm?或者有人知道 Xdebug 或 PhpStorm 中可能导致此问题的任何错误吗?

Xdebug in phpinfo Xdebug in phpinfo

最佳答案

我已经发现了这个问题。无论如何。

禁用“通过未注册的服务器配置忽略外部连接”后,它开始工作。然后我查看了 PhpStorm 中的服务器配置,看起来绝对没问题,所以我再次尝试禁用此设置,效果也很好。

PhpStorm setting

因此,要解决我的问题,我必须:

  1. 转到文件 -> 设置。
  2. 转到语言和框架 -> PHP -> 调试。
  3. 取消选中“通过未注册的服务器配置忽略外部连接”。
  4. 运行脚本以从浏览器触发 Xdebug。
  5. 再次转到设置并再次启用相同的设置。

现在一切都很顺利!

关于phpstorm - Xdebug 与 PhpStorm 在 CLI 中工作正常,而不是在浏览器中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47222927/

相关文章:

php - 尝试使用 xdebug 在 cli 上调试 phpunit 单元测试失败

browser - PHPStorm 使用实时编辑在 Chrome 中打开 index.php?

php - webgrind中自动清除tmp文件

eclipse - 将 XDebug 与 Eclipse PDT 和 XAMPP 结合使用

php - 在 phpstorm 中使用正则表达式使用替换工具删除 php 注释

whitespace - Phpstorm - 即使一行结束后我也可以单击空白,我不希望能够

phpstorm - PhpStorm 中有选择当前行的键盘快捷键吗?

php - 如何让 __debugInfo 与 XDebug 一起工作?

php - 通过 -z 参数加载 xdebug

php - 使用Xdebug和Eclipse调试PHP时报错: "unexpected termination of script, debugging ended",