【发布时间】:2020-11-16 14:33:14
【问题描述】:
问题:我目前无法在 Windows 10 上的 NetBeans 8.2 RC 中调试 php。NetBeans 在右下方显示“等待连接”并且永远不会连接。
我找到的大部分教程都是几年前的:
- Codewall article //2018...最新?
- Michael Milette's Tutorial //看起来很彻底,但从 2014 年开始
- NetBeans site // 引用 php 5...哎呀!
- Rob Prouse's Tutorial //2010
请注意,其中一些对 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
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