【问题标题】:How can I connect Xdebug 3 to PhpStorm on Windows 10?如何在 Windows 10 上将 Xdebug 3 连接到 PhpStorm?
【发布时间】:2021-03-13 11:52:57
【问题描述】:

我正在尝试使用 Xdebug 连接 PhpStorm 并调试 PHP 脚本/网页,我已经做过几次了。

这是我的 php.ini 文件(有趣的一点):

[xdebug]
zend_extension=C:\xampp\php\ext\php_xdebug.dll
xdebug.remote_enable=1
xdebug.remote_port=10000
xdebug.remote_mode=req

我设置了多个断点并在我的索引上调用了xdebug_break(),但代码执行并没有在它们处停止。

这是 Xdebug 的 PhpStorm 验证脚本输出:

netstat 的输出显示 PhpStorm 正在监听 10000 端口:

【问题讨论】:

  • 您是否使用解耦站点。意思是你有一个分离的前端和分离的restfull API?还是您使用的是旧的服务器端渲染方式?
  • 您正在使用 Xdebug v3 ...但仍在使用 Xdebug v2 配置参数。只需使用正确的 v3 参数名称:xdebug.org/docs/upgrade_guide
  • *"...并在我的索引上调用 xdebug_break()...` 请注意 xdebug_break() 在 Xdebug 3 中的工作方式不同:现在它只是作为断点,不会启动调试会话(如果还没有的话)已经存在了。
  • @LazyOne 是的,调试会话是由phpstorm自己发起的
  • 另外,最初我尝试使用 v2 配置参数,但 PhpStorm 没有验证它并且它不起作用。

标签: php xampp phpstorm xdebug


【解决方案1】:

将php.ini中的行改为

xdebug.mode=debug

并将 PhpStorm 上的端口设置为侦听 9003 而不是 9000。

在 xdebug v3 中,默认的 xdebug 端口已更改为 9003: https://xdebug.org/docs/upgrade_guide#Step-Debugging

【讨论】:

    【解决方案2】:

    改变

    来自

    xdebug.remote_enable=1
    xdebug.remote_port=10000
    xdebug.remote_mode=req
    

    进入

    xdebug.mode=debug
    xdebug.start_with_request=yes
    xdebug.client_port=10000
    

    【讨论】:

      猜你喜欢
      • 2016-10-01
      • 2020-09-23
      • 2021-02-25
      • 2018-08-09
      • 2015-09-25
      • 2016-02-12
      • 2021-03-15
      • 2018-04-27
      • 2015-11-10
      相关资源
      最近更新 更多