如何使用 netbeans 和 Xdebug 调试 PHP
我最近尝试使用 Netbeans 6.5 评价如此之高Smashing 杂志对 IDE 的评论。 http://www.smashingmagazine.com/2009/02/11/the-big-php-ides-test-why-use-oneand-which-to-choose/
我从 Notepad++ 切换的主要原因是我希望能够调试我的代码并通过它进行设置。
我已按照供应商 http://xdebug.org/ 和 netbeans web 提供的有关如何安装 xdebug 的说明进行操作地点。 http://www.netbeans.org/kb/docs/php/debugging .html#gettingReady 但无济于事。
它是如何完成的,还有其他人在 netbeans 中进行调试吗?
(我的设置是:Windows XP、Wamp server 2.0、PHP 5、Netbeans 6.5.1)
I have recently tried to get going with Netbeans 6.5 after it rated so highly in the IDE review by Smashing magazine. http://www.smashingmagazine.com/2009/02/11/the-big-php-ides-test-why-use-oneand-which-to-choose/
My main reason for switching from Notepad++ is that I'd like to be able to debug my code and set through it.
I have followed the instructions about how to install xdebug from both the vendor http://xdebug.org/ and the netbeans web site. http://www.netbeans.org/kb/docs/php/debugging.html#gettingReady but to no avail.
How is it done, has anyone else got debugging working in netbeans?
(My setup is: Windows XP, Wamp server 2.0, PHP 5, Netbeans 6.5.1)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(16)
在 php.ini 中添加这一行非常重要:
注意:在 NetBeans 中,转到“设置”并查看 xdebug 内容的设置位置。 查找该会话 ID。 就我而言,它是 netbeans-xdebug。
It's important to add this line in the php.ini:
Note: In NetBeans go to Settings and look where the xdebug stuff is set up. Look for that Session ID. In my case it was netbeans-xdebug.
嗯,对我来说,netbeans 是第一个可以开箱即用进行 php 调试的 ide。
xdebug 是否显示在 phpinfo 中? 如果是这样,它应该可以使用默认设置。 唯一需要的是:
因此,如果未启用此功能,请将其放入您的 php.ini 文件中,重新启动 apache,调试应该可以工作。
如果没有,您将必须向我提供更多信息来帮助您。
西
hm, for me, the netbeans was the first ide that php debugging was working out of the box.
Does the xdebug show in phpinfo? if it does it should work with default settings. the only one that is needed is:
So if this isn't enabled put it in your php.ini file, restart apache, and debugging should work.
If not, you will have to supply more info for me to help you.
sy
我发现 WAMP 在与 Mod_rewrite 和 cURL 一起安装时无法应对 Xdebug。
这是一个已知错误并且每次都会崩溃。
http://phphints.wordpress.com/2008/10/24/wampserver-phpini-settings-for-use-with-xdebugdll-pear-and-silverstripe-cms-framework/
不幸的是,我也使用这两个库。
I have since found that WAMP, when installed with Mod_rewrite and cURL cannot cope with Xdebug.
It is a known error and crashes everytime.
http://phphints.wordpress.com/2008/10/24/wampserver-phpini-settings-for-use-with-xdebugdll-pear-and-silverstripe-cms-framework/
Unfortunately, I am using these 2 libraries too.
xdebug 给出的curl 或mod_rewrite 问题并不是一个已知问题。 我知道的唯一问题是 Vista 上的 Xdebug。
It's not a know problem that xdebug gives issues with curl or mod_rewrite. The only issues I am aware of is with Xdebug on Vista.
你可以在这里看到:
http://ruilima.com/2010/11/ambiente_de_desenvolvimento_php_netbeans_xdebug/
是葡萄牙语,但有一个预配置的虚拟机,带有 Ubuntu 10.10、netbeans、php、mysql、xdebug,可以使用。 看一看
You can see here:
http://ruilima.com/2010/11/ambiente_de_desenvolvimento_php_netbeans_xdebug/
is in Portuguese, but there is a pre configured virtual machine with Ubuntu 10.10, netbeans, php, mysql, xdebug, ready to use. take a look
我发现在Netbeans中你需要将项目中的webroot路径设置为app/webroot。 如果你这样做,调试工作就会完美无缺。
I found out that in Netbeans you need to set the webroot path in the projects to app/webroot. If you do this debugging works flawlessly.
如果您在Windows下使用xampp:
您只需打开您的php.ini文件并将这两行更改
为
(注意:如果您的xampp版本较旧,则必须从http://xdebug.org/download.php,即使您的操作系统是 64 位,也下载 32 位版本,例如 xdebug 的名称。你下载的是php_xdebug-2.2.1-5.4-vc9.dll,首先将php_xdebug-2.2.1-5.4-vc9.dll复制到目录C:\xampp\php\ext\,然后你的第二行是 zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.1-5.4-vc9.dll)
之后停止 apache 并再次启动,就是这样。
If you are using xampp under Windows:
You only need to open your php.ini file and change these two lines
into
(Caution: If your xampp version is old, you must download it from http://xdebug.org/download.php, download the 32 bit even your OS is 64 bit. E.g. the xdebug's name you downloaded is php_xdebug-2.2.1-5.4-vc9.dll. First copy php_xdebug-2.2.1-5.4-vc9.dll to the directory C:\xampp\php\ext\, then your the second line will be
zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.1-5.4-vc9.dll
)After that stop apache and start again, that's it.
如果您遇到这样的问题:每次运行调试器时 Apache 都会崩溃(这就是我遇到的情况,非常烦人)。 我相当确定我重新安装了 xampp 并重新设置了 xdebug。 我认为问题在于 zend-debugger 在 php.ini 中的设置很奇怪,而我没有修改正确的 php.ini。
最终,在重新安装和重置后,我发现它工作正常。
我现在运行 Netbeans 的开发版本,它使用 xdebug 进行网络调试,因此我们可以在开发服务器上运行它,并且效果很好。
祝你好运,没有任何关于如何使用 net beans 设置 xdebug 的特别好的文档。
If you're having the problem in which Apache decides to crash whenever you run the debugger (which is what I had and is extremely annoying). I'm fairly sure I re-installed xampp and re-set up xdebug. I think the problem was to do with the zend-debugger being set up weirdly in php.ini and me not modifying the correct php.ini.
Eventually after re-installing and resetting it up I got it working fine.
I now run a dev release of Netbeans which has networked debugging with xdebug so we run it all off of our development server and it works a treat.
Good Luck, There isn't particularly any decent documentation on how to set up xdebug with net beans.
我偶尔会遇到 NetBeans 和 XDebug 问题,这些问题是由于 Watch 语句与正在调试的代码无关而导致的。
在这种情况下,调试器会因套接字异常而失败。
如果您发现这导致了您的问题,请将手表取下。 一般来说,我发现 XDebug 非常方便!
不过,我确实意识到这可能与您遇到的问题无关,但值得注意。
I have had occasional issues with NetBeans and XDebug which have been down to a Watch statement being in place which does not relate to the code being debugged.
In this case the debugger just fails with a Socket Exception.
Remove any watches if you find this is causing your issue. Generally though I have found XDebug to be extremely handy!
I do realise however that this may not relate to the issue you have here but it's worth being aware of.
在同一站点上找到了相同问题的解决方案 PHP Netbeans: xdebug 在每个 include() 或 require() 处停止
found the solution of the same problem on the same site PHP Netbeans: xdebug stops on every include() or require()
错误的行为是,忘记将其
作为 php-ini 中的节标题。 当然,在另一个部分开始之前“停放”你的东西(例如[日期]或[iconv]),否则你会不小心将它们放在错误的部分中。 (在 php.ini 的注释 djungle 中,这很容易发生。)
Well wrongdoing was, forgetting
as a section header in php-ini. And of course, "park" your stuff right before another section start (e.g. [Date] or [iconv]) otherwise you will accidetenly place those in the wrong section. (In the comment djungle of php.ini this happens easily.)
就我而言,它是在我的计算机(Windows 7)上运行的一个进程,该进程使用端口 9000,已称为 aeagent.exe
我将 php.ini 设置更改为“xdebug.remote_port=9001”,在 netbeans 中进行了相应的更改,然后重新启动阿帕奇。 现在可以了。
感谢 SysInternals TCPView 工具。
In my case it was a process running on my machine (Windows 7) that was using port 9000 already called aeagent.exe
I changed my php.ini setting to "xdebug.remote_port=9001", made the corresponding change in netbeans, then restarted Apache. Now it works.
Thanks to SysInternals TCPView tool.
转到 http://wiki.netbeans.org/HowToConfigureXDebug 。 您应该遵循的一系列步骤可能会对您有所帮助。
但很可能您只需要新版本的 xdebug-binary。 转到 http://xdebug.org/wizard.php 找出您需要的二进制文件和您的问题可能会得到解决。
Go to http://wiki.netbeans.org/HowToConfigureXDebug . There is a big list of steps you should follow, that might help you out.
But most likely you just need a new version of xdebug-binary. Go to http://xdebug.org/wizard.php to find out what binary you need und your problem might be solved.
在Ubuntu下运行netbeans时,我也遇到了这个问题,似乎我已经尝试了互联网上找到的所有解决方案,但都是徒劳。
最终唯一有帮助的是使用 SUDO 命令运行 netbeans! 看起来普通用户没有权限侦听端口 9000(或任何其他端口)。
...瞧,我可以再次调试了! 也许它会节省你一两天的时间
When running netbeans under Ubuntu, I was facing this issue too, it seems that I have tried all solutions found in internet but all in vain.
The only thing that finally helped was running netbeans with SUDO command! Looks like regular user didn't have permission to listen on port 9000 (or any other).
...and voila, I can debug again! Maybe it'll save you a day or two
现在,在浪费 3 个小时让 xdebug 在 Windows8 上使用 wamp 2.2 工作之后,它可以工作了
将 [xdebug] 下面的原始行替换为以下内容
现在单击任务栏中的 wamp 图标并“重新启动所有服务”
好吧..现在最后一步>>以管理员身份启动 NETBEANS
windows8 的冬青灵魂我恨你:<
Now its working after Wasting the 3 hours for making xdebug work on Windows8 with wamp 2.2
replacing original lines below [xdebug] with following
Now click on wamp icon in taskbar and "restart all services"
Well..Now final step>>START NETBEANS AS ADMINISTRATOR
Holly soul of windows8 i hate you :<
请阅读以下文档以使用 NetBeans 进行远程调试。
http://stuporglue。 org/setting-up-xdebug-with-netbeans-on-windows-with-a-remote-apache-server/
Go through the below document for remote debugging using NetBeans.
http://stuporglue.org/setting-up-xdebug-with-netbeans-on-windows-with-a-remote-apache-server/