【问题标题】:Trying to Debug on Windows with PHP 7.4 and NetBeans 8.2 RC under XAMPP 3.2.4尝试在 XAMPP 3.2.4 下使用 PHP 7.4 和 NetBeans 8.2 RC 在 Windows 上进行调试
【发布时间】:2020-11-16 14:33:14
【问题描述】:

问题:我目前无法在 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 信息

netbeans 等待连接时的“netstat -an”结果 注意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>

【问题讨论】:

  • 1) "嗯...PHP 版本设置为 7.0,我正在尝试使用 7.4...但它说“PHP 版本仅用于提示”。是这只是“NetBeans 8.2 RC 不支持 PHP 7.4”的简单案例?” 我不是 NetBeans 用户.. 但这看起来像 PHP 语言级别,而不是实际的 PHP 解释器/可执行文件。编辑器/检查使用语言级别来告诉您没有使用较新 PHP 版本的功能(因此您的代码将在该 PHP 版本上工作并且不会失败)
  • 2) “NetBeans 在右下角显示“正在等待连接”并且从不连接。” 以防万一:它是 Xdebug 连接到 IDE 而不是其他方式。所以您需要检查: 2.1) 实际/实时 Xdebug 设置 -- 发布phpinfo() 输出的整个 Xdebug 部分 2.2) 也许 NetBeans 无法侦听 TCP 9000 端口?检查netstat 或类似的,以查看当 IDE 侦听传入连接时哪个进程使用它。
  • 2.3) 为这种不成功的调试会话收集和共享 Xdebug 日志(尽量不要将多个会话混合在一​​起:中间为空日志)——它会告诉它是否尝试连接以及结果是什么.
  • 已编辑以包含 phpinfo 的 xdebug 部分、netstat 结果和来自单个会话的 xdebug 错误转储。我还应该注意,我尝试更改启动浏览器的行为,但直到我点击停止后它才会使用“?XDEBUG_SESSION_START=netbeans-xdebug”标志启动......似乎很奇怪。那时(并且当生成 xdebug 转储时)浏览器正在“等待本地主机”上旋转,而 netbeans 正在“等待连接”上旋转。
  • 顺便说一句,我注意到 xdebug 转储的时间戳显示“日志在 2020-07-27 15:49:37 打开”......但我在泰国曼谷,现在是 22:这里是 49,而不是 15:49。这会搞砸一切吗?请注意,我确实在 php.ini 文件中将 timezome 设置为 Asia/Bangkok。也许我还需要在其他地方设置它?

标签: php netbeans xampp xdebug netbeans-8.2


【解决方案1】:

对于试图让 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

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

【讨论】:

  • 注意:Mods,如果回答这是错误的举动,请随意编辑/删除/等。我理解回答“我如何解决 X 问题?”用“不要问那个,问这个其他问题”并不是一个好的答案。我只是不确定如何最好地保留我尝试过的内容以及我登陆的内容而不将其发布为答案。谢谢。
猜你喜欢
  • 2021-08-06
  • 2020-11-21
  • 1970-01-01
  • 2018-12-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-06
  • 2020-05-19
相关资源
最近更新 更多