1

问题:我目前无法在 Windows 10 上的 NetBeans 8.2 RC 中调试 php。NetBeans 在右下方显示“等待连接”并且从不连接。

我发现的大多数教程都是几年前的:

请注意,其中一些对 php.ini 中的内容有不同的说明

Xdebug 东西

phpinfo()将 Xdebug 列为运行版本 2.9.4,IDE 密钥为:netbeans-xdebug,因此至少可以识别它。相关的 php.ini [XDebug] 信息:

...
output_buffering=off
...
[XDebug]
zend_extension = "c:\xampp\php\ext\php_xdebug-2.9.4-7.4-vc15-x86_64.dll"
xdebug.idekey = netbeans-xdebug
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "c:\xampp\tmp"
;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_autostart = 0
xdebug.remote_connect_back = 0
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_log="c:\xampp\tmp\xdebug.txt"
xdebug.remote_port = 9000
xdebug.show_local_vars = 9
xdebug.trace_output_dir = "c:\xampp\tmp"
; 3600 (1 hour), 36000 = 10h
xdebug.remote_cookie_expire_time = 36000

来自 phpinfo() 的 xdebug 信息 xdebug_1 xdebug_2 xdebug_3

'netstat -an' 结果,而 netbeans 正在等待连接 在此处输入图像描述 注意 57418 和 9000 之间的双向连接

xdebug 错误日志

[10112] Log opened at 2020-07-27 15:33:34
[10112] I: Connecting to configured address/port: 127.0.0.1:9000.
[10112] E: Time-out connecting to client (Waited: 200 ms). :-(
[10112] Log closed at 2020-07-27 15:33:34

[10112] Log opened at 2020-07-27 15:33:47
[10112] I: Connecting to configured address/port: 127.0.0.1:9000.
[10112] I: Connected to client. :-)
[10112] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/xampp/apps/wordpress/htdocs/index.php" language="PHP" xdebug:language_version="7.4.0" protocol_version="1.0" appid="10112" idekey="netbeans-xdebug"><engine version="2.9.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>

[10112] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>

[10112] Log closed at 2020-07-27 15:33:51

[10112] Log opened at 2020-07-27 15:33:52
[10112] I: Connecting to configured address/port: 127.0.0.1:9000.
[10112] E: Time-out connecting to client (Waited: 200 ms). :-(
[10112] Log closed at 2020-07-27 15:33:52

[10112] Log opened at 2020-07-27 15:34:05
[10112] I: Connecting to configured address/port: 127.0.0.1:9000.
[10112] I: Connected to client. :-)
[10112] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/xampp/apps/wordpress/htdocs/index.php" language="PHP" xdebug:language_version="7.4.0" protocol_version="1.0" appid="10112" idekey="netbeans-xdebug"><engine version="2.9.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>

php_xdebug-2.9.4-7.4-vc15-x86_64.dll 是 xdebug.org/wizard 推荐的 dll,位于预期的文件位置。

NetBeans 配置

由于我正在尝试调试 WordPress 插件,因此我将整个 'wordpress' 目录作为我在 NetBeans 中的项目。

资料来源:

项目属性

嗯...PHP 版本设置为 7.0,我正在尝试使用 7.4...但它说“PHP 版本仅用于提示”。这只是“NetBeans 8.2 RC 不支持 PHP 7.4”的简单案例吗?

运行配置:

运行配置

任何帮助表示赞赏。提前致谢。编辑:包括来自 phpinfo()、netstat 结果和 xdebug 转储的 xdebug 信息。

可能有帮助在更改行为以再次启动浏览器后,我注意到我点击停止 之前,该项目没有加载“?XDEBUG_SESSION_START=netbeans-xdebug”标志。这对我来说似乎很奇怪,但我尝试启动调试器,点击停止(使用标志启动网站),然后附加调试器。它不起作用(NetBeans 在“等待连接”上旋转,Chrome 在“等待本地主机”上旋转)。Chrome 最终会加载,但是当我尝试开始导航到站点的一部分以运行我正在尝试调试的 php 代码时,它会返回到使用以下 xdebug 转储旋转“等待本地主机”(它从不导航远离主页):

[22340] Log opened at 2020-07-27 15:49:37
[22340] I: Connecting to configured address/port: 127.0.0.1:9000.
[22340] I: Connected to client. :-)
[22340] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/xampp/apps/wordpress/htdocs/index.php" language="PHP" xdebug:language_version="7.4.0" protocol_version="1.0" appid="22340" idekey="netbeans-xdebug"><engine version="2.9.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>
4

1 回答 1

-2

对于试图让 NetBeans 工作的可怜人来说,答案是……不要使用 NetBeans。我知道这是一个糟糕的答案,但是经过 5 个小时的努力,与 20 分钟让 VSCode 工作的 NetBeans 相比,它是没有意义的(除非你有其他使用它的理由)。

为了让 VSCode 正常工作,我主要遵循本教程:https ://stackify.com/php-debugging-guide/

结合以下 php.ini 设置:

...
output_buffering=off
...
[XDebug]
zend_extension = "c:\xampp\php\ext\php_xdebug-2.9.4-7.4-vc15-x86_64.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1

请注意我实际需要的设置有多么少!

于 2020-07-28T08:48:28.563 回答