在本地网络服务器 (xampp) 和 php 7 上设置 Xdebug?

Setup Xdebug on local webserver (xampp) and php 7?

我尝试开始 Xdebug 好几个小时都没有成功。

首先,我通过访问这个 official link 来确定我需要哪个 php_xdebug.dll 版本,然后按照他们的说明进行操作。

Summary
Xdebug installed: 2.6.0
Server API: Apache 2.0 Handler
Windows: yes - Compiler: MS VC15 - Architecture: x86
Zend Server: no
PHP Version: 7.2.3
Zend API nr: 320170718
PHP API nr: 20170718
Debug Build: no
Thread Safe Build: yes
Configuration File Path: C:\WINDOWS
Configuration File: A:\xampp\php\php.ini
Extensions directory: A:\xampp\php\ext
You're already running the latest Xdebug version
But here are the instructions anyway:

1. Download php_xdebug-2.6.0-7.2-vc15.dll
2. Move the downloaded file to A:\xampp\php\ext
3. Update A:\xampp\php\php.ini and change the line
   zend_extension = A:\xampp\php\ext\php_xdebug-2.6.0-7.2-vc15.dll
4. Restart the webserver

这是我的 php.ini 片段:

[XDebug]
zend_extension="A:\xampp\php\ext\php_xdebug-2.6.0-7.2-vc15.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.remote_enable = on
xdebug.remote_handler = "dbgp"
xdebug.remote_host = localhost
xdebug.remote_port = 9001
xdebug.trace_output_dir = "A:\xampp\tmp"
xdebug.remote_log = "A:\xampp\tmp\xdebug\xdebug.log"
xdebug.idekey = "netbeans-xdebug"
xdebug.remote_autostart = on
xdebug.remote_connect_back = on

我相应地在 netbeans 中设置了 portidekey(工具 -> 选项 -> PHP -> 调试)。

...我还确保项目正在使用设置(项目 -> 属性 -> 运行 配置)

我重新启动了 NetBeans 和 Apache。 我什至安装了扩展 "Xdebug helper" 和 "NetBeans Connector"。 Xdebug 帮助程序扩展已配置并设置为调试模式。


现在我设置了一个断点。但是在源代码中右键单击并单击 "Debug File" 后,我得到 "Waiting For Connection (netbeans-xdebug)",它会永远加载。

我也无法点击调试按钮,它们都是灰色的:

我总是使用以下参数调用目标站点,如 official documentation 中的说明:?XDEBUG_SESSION_START=netbeans-xdebug


我尝试了与 SO 上其他问题不同的解决方案,但没有任何帮助。

我已经尝试将 php.ini 中的 xdebug.remote_host 行更改为我的本地 ipv4 地址,但没有任何区别。我还测试了不同的端口。当然,我总是在 php.ini.

中更改某些内容后重新启动 apache

我正在使用 Windows 10 Pro 64 位和 Chrome。

有什么想法吗?在此先感谢您的帮助!


更多:

我检查了我的防火墙,端口没有被阻止。

感谢@LazyOne 的提示,我得以解决。检查我发现的日志后,netbeans 尝试连接到随机 ip 地址:

Log opened at 2018-04-10 21:14:12
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Remote address found, connecting to 74.84.178.15:9001.
E: Time-out connecting to client (Waited: 200 ms). :-(
Log closed at 2018-04-10 21:14:12

Log opened at 2018-04-10 21:17:27
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Remote address found, connecting to 212.112.65.234:9001.
E: Time-out connecting to client (Waited: 200 ms). :-(
Log closed at 2018-04-10 21:17:27

Log opened at 2018-04-10 21:19:22
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Remote address found, connecting to 57.101.242.52:9001.
E: Time-out connecting to client (Waited: 200 ms). :-(
Log closed at 2018-04-10 21:19:22

我立刻知道这与随机更改 IP 地址的 chrome 扩展程序 ipflood 有关。禁用后有效!