简体   繁体   English

带有Mamp的XDebug在NetBeans中不起作用

[英]XDebug with Mamp doesn't work in NetBeans

I have used XDebug semi-sucessfully with PhpStorm and Mamp, but now I want to try using NetBeans for a project. 我已经在PhpStorm和Mamp中成功使用了XDebug,但现在我想尝试将NetBeans用于项目。 But I can't get NetBeans to connect to XDebug. 但是我无法让NetBeans连接到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. 它只是等到我停止调试器后,才收到一条消息,提示NetBeans从未与XDebug建立连接,并且它要求我检查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: 现在,正如我所说的,它与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  

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. 我发现很奇怪的一件事是,每个人都在谈论php.ini位于/ Applications / Mamp / conf中,但至少在该文件夹中没有php.ini。 In /Applications/Mamp/bin/php/php5.3.6/conf on the other hand, there is. 另一方面,在/Applications/Mamp/bin/php/php5.3.6/conf中。 So that's the one I have modified. 这就是我修改过的那个。 And since it works in PhpStorm I figure it must be right... 由于它可以在PhpStorm中使用,所以我认为它一定是正确的...

But then, why isn't NetBeans able to connect? 但是,为什么NetBeans无法连接? I'm also using the XDebug plugin for Safari to hook it up in the browser. 我还使用Safari的XDebug插件将其连接到浏览器中。 And the port in NetBeans is set to 9000 as in the php.ini file. 和php.ini文件中一样,NetBeans中的端口设置为9000。

I'm using NetBeans 7.0.1 and php5.3.6. 我正在使用NetBeans 7.0.1和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. 好吧,我发现了为什么XDebug仍然无法连接的问题:我正在使用Safari的外接程序进行XDebug调试,显然它具有自己的IDE Key设置,设置为1,而NetBeans设置了netbeans-xdebug。 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 它说:当我点击调试器时,找不到404页面,并且地址字段中的地址是: 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) 顺便说一句,只要在NetBeans内部运行即可正常工作并打开http:// localhost / app_netbeans (我已使用mod_rewrite在CodeIgniter中删除了URL的index.php部分)

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. 编辑2:我发现地址的index.php部分是因为在NetBeans的运行配置中,有一个“索引文件”设置,默认情况下设置为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. 如果我删除了CodeIgniter“ controller”网址而没有index.php,我得到了正确的网址,但后面附加了xdebu内容。 But still I get the 404 Page not found when I use the debugger command, but not when I use the run command. 但是,当我使用debugger命令时,却仍然找不到404页面,但是当我使用run命令时,却找不到。

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. 足够奇怪的是,我可以执行debug,忽略未找到404 Page的事实,然后回到IDE,单击run,如果设置了断点,它将在该断点处停止。

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... 再次重申,这并不是我认为正常的调试行为。因此,如果有人知道发生了什么,我希望听到它...

Use this config and make sure you update Netbeans to use port 9001. 使用此配置,并确保您将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"

I found that the port 9000 sometimes conflicts with other applications, and xdebug seems to fail silently if it cant use it. 我发现端口9000有时会与其他应用程序发生冲突,并且xdebug如果无法使用它,似乎会无声地失败。

Mine is finally working, so I wanted to post my full php.ini configuration: 我的终于可以了,所以我想发布完整的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"

You may also check if your project is configured to copy to a different directory in the Netbeans project settings. 您还可以检查您的项目是否配置为复制到Netbeans项目设置中的其他目录。 After I changed this setting I had to restart Netbeans and MAMP using the quit command. 更改此设置后,我不得不使用quit命令重新启动Netbeans和MAMP。

Just to note: 请注意:

  • No index.php in my start up properties 我的启动属性中没有index.php
  • Stop at first line is turned off in debugging preferences 在调试首选项中关闭在第一行停止
  • I do think changing to port 9001 made a difference on my system 我确实认为更改为9001端口对我的系统有所影响

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. 并确保netbeans中的端口正确。 you can check that in 你可以检查一下

  1. goto tools menu and select options 转到工具菜单并选择选项
  2. in options click on the php and check the port number. 在选项中,单击php并检查端口号。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM