【问题标题】:PHPStorm ignores Xdebug request from GuzzlePHPStorm 忽略来自 Guzzle 的 Xdebug 请求
【发布时间】:2015-03-17 15:50:45
【问题描述】:

我已将 Guzzle 设置为在向我的 API 发出请求时包含 Xdebug cookie。我在/etc/httpd/conf/httpd.conf 中添加了以下行,以便在请求通过时查看 cookie:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Cookie}i\"" common

如果我通过 Chrome REST 控制台使用此 cookie 发出请求,xdebug 会遇到断点。访问日志中的请求是:

192.168.50.1 - - [17/Mar/2015:15:47:36 +0000] "GET /app_dev.php/user?id=1&authuserid=1 HTTP/1.1" 301 569 "XDEBUG_SESSION=PHPSTORM"

当 Guzzle 发出同样的请求时,没有命中断点。

127.0.0.1 - - [17/Mar/2015:15:42:17 +0000] "GET /app_dev.php/user?id=1 HTTP/1.1" 301 501 "XDEBUG_SESSION=PHPSTORM"

显然我们缺少authuserid 作为 GET 参数,但这不应该影响 xdebug。如果这被 Guzzle 设置为隐藏的 cookie,那可能就是我需要设置 xdebug 会话的地方?

我以前有这个工作,但现在我完全迷失了。

【问题讨论】:

  • 你试过用GET参数代替cookie吗?

标签: apache phpstorm xdebug guzzle


【解决方案1】:

我的 xdebug 配置(/etc/php.d/15-xdebug.ini 或)是:

zend_extension="/usr/lib64/php/modules/xdebug.so"
xdebug.idekey="PHPSTORM"
xdebug.remote_host=192.168.50.1
xdebug.remote_port=9000
xdebug.remote_connect_back=1
xdebug.remote_enable=1
xdebug.profiler_enable=1
xdebug.profiler_output_dir="<AMP home\tmp>"

将我的配置减少到:

zend_extension="/usr/lib64/php/modules/xdebug.so"
xdebug.remote_host=192.168.50.1
xdebug.remote_port=9000
xdebug.remote_enable=1

允许我的 API 连接到 xdebug。

通过消除过程,至少有一个罪魁祸首是:

xdebug.remote_connect_back=1

xdebug.remote_connect_back
类型:boolean,默认值:0,在Xdebug中引入> 2.1 如果启用,xdebug.remote_host设置 被忽略,Xdebug 将尝试连接到客户端 HTTP 请求。它检查 $_SERVER['REMOTE_ADDR'] 变量以找到 找出要使用的 IP 地址。请注意,没有过滤器 可用,任何可以连接到网络服务器的人都将是 能够启动调试会话,即使他们的地址没有 匹配 xdebug.remote_host。

虽然我仍然不明白为什么在这种情况下这会影响 xdebug 的功能,因为应用程序和 API 都在我的虚拟机上。

【讨论】:

  • 从您的日志中:192.168.50.1(您的物理机 IP,PhpStorm 正在运行的位置——从 VM 中看到)vs 127.0.0.1(您的本地 VM)。 P.S. 您应该提到它是在 VM 上运行的远程调试/运行。对于本地来说,它不会有任何区别,但对于远程......
猜你喜欢
  • 2021-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-07
  • 2016-12-17
相关资源
最近更新 更多