使用 Mamp 进行 XDebug 在 NetBeans 中不起作用

发布于 2024-12-10 10:53:09 字数 1800 浏览 0 评论 0原文

我已经将 XDebug 与 PhpStorm 和 Mamp 结合使用,但现在我想尝试在项目中使用 NetBeans。但我无法让 NetBeans 连接到 XDebug。它只是等待,直到我停止调试器,然后我收到一条消息,指出 NetBeans 从未连接到 XDebug,并要求我检查 php.ini 中的设置。

现在,正如我所说,它与 PhpStorm 一起工作正常,所以我认为 php.ini 中的设置应该没有任何问题,但无论如何,它们是:

[xdebug]
zend_extension="/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp 
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000  

我发现奇怪的一件事是每个人都在谈论 php .ini 位于 /Applications/Mamp/conf 中,但在该文件夹中至少在我的设置中没有 php.ini。另一方面,在 /Applications/Mamp/bin/php/php5.3.6/conf 中,有。这就是我修改过的。既然它在 PhpStorm 中工作,我认为它一定是正确的......

但是,为什么 NetBeans 无法连接?我还使用 Safari 的 XDebug 插件将其连接到浏览器中。 NetBeans 中的端口设置为 9000,如 php.ini 文件中所示。

我正在使用 NetBeans 7.0.1 和 php5.3.6。

我还缺少什么吗?

编辑:

好吧,我发现了为什么 XDebug 无论如何都无法连接的问题:我正在使用 Safari 的加载项进行 XDebug,显然它有自己的 IDE Key 设置,设置为 1,而 NetBeans 有 netbeans-xdebug放。当我在加载项中将其更改为后者后,我就建立了连接。问题是我仍然遇到某种错误。它说:当我点击调试器时找不到404页面,地址字段中的地址是: http://localhost/app_netbeans/index.php?XDEBUG_SESSION_START=netbeans-xdebug

知道这里发生了什么吗?

顺便说一句,只需在 NetBeans 中运行即可正常工作并打开 http://localhost/app_netbeans (我已使用 mod_rewrite 删除索引CodeIgniter 中 url 的 .php 部分)

编辑 2: 我发现该地址的index.php部分是因为在NetBeans的运行配置中有一个“索引文件”设置,默认设置为index.php。如果我删除它以获得没有index.php的CodeIgniter“控制器”url,我得到了正确的url,但在它后面附加了xdebu内容。但当我使用 debugger 命令时,我仍然收到 404 Page not found 的消息,但当我使用 run 命令时却没有。

奇怪的是,我可以做的是我可以点击调试,忽略它进入 404 Page not find 的事实,然后返回 IDE,点击运行,如果我设置了断点,它将在该断点处停止。

但同样,这并不完全是我所认为的正常调试行为......所以如果有人知道发生了什么,我很想听听......

I have used XDebug semi-sucessfully with PhpStorm and Mamp, but now I want to try using NetBeans for a project. But I can't get NetBeans to connect to XDebug. It just waits until I stop the debugger and then I get a message that NetBeans never got a connection to XDebug, and it asks me to check the settings in php.ini.

Now, as I said it has worked ok with PhpStorm, so I don't think there should be anything wrong with the settings in php.ini, but anyway, here they are:

[xdebug]
zend_extension="/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp 
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000  

One thing that I found strange was that everyone talks about php.ini being located in /Applications/Mamp/conf, but in that folder there is no php.ini in my setup at least. In /Applications/Mamp/bin/php/php5.3.6/conf on the other hand, there is. So that's the one I have modified. And since it works in PhpStorm I figure it must be right...

But then, why isn't NetBeans able to connect? I'm also using the XDebug plugin for Safari to hook it up in the browser. And the port in NetBeans is set to 9000 as in the php.ini file.

I'm using NetBeans 7.0.1 and php5.3.6.

Anything else I'm missing?

EDIT:

Well, I found the problem for why XDebug wasn't connecting anyway: I am using the add-in for Safari for XDebug, and apparently it had it's own setting for IDE Key, set to 1, while NetBeans had netbeans-xdebug set. Once I changed it to the latter in the add-in I got a connection. The problem is I still get some sort of error. It says: 404 Page not found when I hit the debugger, and the address in the address field is: http://localhost/app_netbeans/index.php?XDEBUG_SESSION_START=netbeans-xdebug

Any idea what is going on here?

BTW, just hitting run inside NetBeans works fine and opens http://localhost/app_netbeans (I have used mod_rewrite to remove the index.php part of urls in CodeIgniter)

EDIT 2:
I found that the index.php part of the address was because in the run configuration in NetBeans there was an "index file" setting that was set by default to index.php. If I removed that to have CodeIgniter "controller" urls without the index.php I got the correct url, but with the xdebu stuff appended after it. But still I get the 404 Page not found when I use the debugger command, but not when I use the run command.

Weirdly enough what I can do is I can hit debug, ignore the fact that it goes to 404 Page not found, and go back to the IDE, hit run and if I have a breakpoint set it will then stop at that breakpoint.

But again, this is not exactly what I would consider normal debugging behaviour... So if anyone knows what is going on I would love to hear it...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风向决定发型 2024-12-17 10:53:09

使用此配置并确保更新 Netbeans 以使用端口 9001。

[xdebug]

zend_extension="/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"

xdebug.remote_host=localhost
xdebug.remote_port=9001
xdebug.remote_enable=1
xdebug.idekey="netbeans-xdebug"

我发现端口 9000 有时与其他应用程序冲突,并且如果 xdebug 无法使用它,它似乎会默默地失败。

Use this config and make sure you update Netbeans to use port 9001.

[xdebug]

zend_extension="/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"

xdebug.remote_host=localhost
xdebug.remote_port=9001
xdebug.remote_enable=1
xdebug.idekey="netbeans-xdebug"

I found that the port 9000 sometimes conflicts with other applications, and xdebug seems to fail silently if it cant use it.

快乐很简单 2024-12-17 10:53:09

使用以下代码..

zend_extension="path to the xdebug.so"
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
[xdebug]
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000

并确保 netbeans 中的端口正确。 中检查

  1. 您可以在转到工具菜单
  2. 并选择选项中的选项,单击 php 并检查端口号。

在此处输入图像描述

use the following code..

zend_extension="path to the xdebug.so"
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
[xdebug]
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000

and also make sure the port in the netbeans is correct. you can check that in

  1. goto tools menu and select options
  2. in options click on the php and check the port number.

enter image description here

忆梦 2024-12-17 10:53:09

我的终于可以工作了,所以我想发布完整的 php.ini 配置:

[xdebug]
; got this script from https://netbeans.org/kb/docs/php/configure-php-environment-mac-os.html
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9001
xdebug.remote_autostart=1
xdebug.idekey="netbeans-xdebug"
zend_extension="/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.remote_log="/Applications/MAMP/logs/xdebug_remote.log"

您还可以检查您的项目是否配置为复制到 Netbeans 项目设置中的其他目录。更改此设置后,我必须使用 quit 命令重新启动 Netbeans 和 MAMP。

只是要注意:

  • 我的启动属性中没有index.php
  • 在调试首选项中关闭了第一行停止
  • 我确实认为更改为端口 9001 对我的系统产生了影响

Mine is finally working, so I wanted to post my full php.ini configuration:

[xdebug]
; got this script from https://netbeans.org/kb/docs/php/configure-php-environment-mac-os.html
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9001
xdebug.remote_autostart=1
xdebug.idekey="netbeans-xdebug"
zend_extension="/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.remote_log="/Applications/MAMP/logs/xdebug_remote.log"

You may also check if your project is configured to copy to a different directory in the Netbeans project settings. After I changed this setting I had to restart Netbeans and MAMP using the quit command.

Just to note:

  • No index.php in my start up properties
  • Stop at first line is turned off in debugging preferences
  • I do think changing to port 9001 made a difference on my system
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文