【发布时间】:2017-05-16 08:13:37
【问题描述】:
使用 MacOS Sierra、PhpStorm 和 Xdebug,在端口 80 上配置的 Web 应用程序(不从 PhpStorm 运行)。
浏览到localhost:80/index.php时,PhpStorm不会在断点处停止,当访问外部IP192.168.1.2/index.php时,PhpStorm会遇到断点。
我想使用localhost而不是外部IP进行调试。
有没有办法让 PhpStorm 与 localhost 一起工作?
P.S. Visual Studio Code 在这两种情况下都适用(因此我相信 Xdebug 和 PhpStorm 运行良好)。
[xdebug]
zend_extension = /usr/local/Cellar/php56/5.6.29_5/lib/php/extensions/debug-non-zts-20131226/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.idekey=vagrant
xdebug.remote_host=0.0.0.0
尝试将 xdebug.remote_host 设置为 127.0.0.1 和 localhost,行为相同。
调试localhost:80时,xdebug log显示:
Log opened at 2017-01-03 14:06:36
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to ::1:9000.
W: Creating socket for '::1:9000', poll success, but error: Operation now in progress (19).
E: Could not connect to client. :-(
Log closed at 2017-01-03 14:06:36
使用 VS Code 时,没有错误,xdebug 显示改为I: Connected to client. :-)
【问题讨论】:
-
请分享您的 PhpStorm 设置。现在可能是您在 PhpStorm 中为 IP 地址创建了“调试服务器”条目——在
Settings/Preferences | Languages & Frameworks | PHP | Servers进行检查。如果一切顺利——收集与 xdebug 相关的日志(来自 IDE 和 xdebug 方面)。 -
(仅供参考) PhpStorm 论坛也一样 -- intellij-support.jetbrains.com/hc/en-us/community/posts/…
-
感谢@LazyOne,我确实尝试过更改服务器设置,尽管它们是在 PHPStorm 检测到连接时自动创建的(通过外部 IP 连接时)。
-
更新了问题,@LazyOne,在 xdeubg 日志之后,我可以看到将 'xdebug.remote_connect_back' 更改为 0 确实使 PHPStorm 和 xdebug 与 localhost 一起工作
-
因为它现在有效——发布您的解决方案并附上解释作为答案——将对处于类似情况的其他用户有用(回复的帖子将更容易找到..另外它表明帖子包含有用的信息)