使用Mamp的XDebug在NetBeans中不起作用

时间:2011-10-17 22:35:46

标签: php netbeans mamp xdebug

我已经使用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 for 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的index.php部分)

编辑2: 我发现地址的index.php部分是因为在NetBeans的运行配置中有一个“索引文件”设置,默认设置为index.php。如果我删除了没有index.php的CodeIgniter“controller”url我得到了正确的url,但是后面附加了xdebu的东西。但是当我使用调试器命令时仍然没有找到404页面,但是当我使用run命令时却没有找到。

奇怪的是,我能做的就是我可以点击调试,忽略它找到404 Page的事实,然后回到IDE,点击运行,如果我有一个断点设置,它将在那个断点处停止

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

3 个答案:

答案 0 :(得分:3)

使用此配置并确保更新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无法使用它,它似乎会无声地失败。

答案 1 :(得分:0)

使用以下代码..

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. 选项中的
  3. 单击php并检查端口号。
  4. enter image description here

答案 2 :(得分:0)

我终于工作了,所以我想发布我的完整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会对我的系统产生影响
相关问题