如何使用 netbeans 和 Xdebug 调试 PHP

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/693074/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 23:31:35  来源:igfitidea点击:

How to debug PHP with netbeans and Xdebug

phpdebuggingnetbeansxdebug

提问by Jon Winstanley

I have recently tried to get going with Netbeans6.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/

我最近尝试使用Netbeans6.5,因为它在 Smashing 杂志的 IDE 评论中获得了如此高的评价。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.

我从 Notepad++ 切换的主要原因是我希望能够调试我的代码并通过它进行设置。

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#gettingReadybut to no avail.

我已按照有关如何从供应商http://xdebug.org/和 netbeans 网站安装 xdebug 的说明进行操作。http://www.netbeans.org/kb/docs/php/debugging.html#gettingReady但无济于事。

How is it done, has anyone else got debugging working in netbeans?

它是如何完成的,有没有其他人在 netbeans 中进行调试?

(My setup is: Windows XP, Wamp server 2.0, PHP 5, Netbeans 6.5.1)

(我的设置是:Windows XP、Wamp server 2.0、PHP 5、Netbeans 6.5.1)

采纳答案by Jon Winstanley

I have since found that WAMP, when installed with Mod_rewrite and cURL cannot cope with Xdebug.

从那以后,我发现 WAMP 与 Mod_rewrite 和 cURL 一起安装时无法处理 Xdebug。

It is a known errorand crashes everytime.

这是一个已知错误,每次都会崩溃。

http://phphints.wordpress.com/2008/10/24/wampserver-phpini-settings-for-use-with-xdebugdll-pear-and-silverstripe-cms-framework/

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.

不幸的是,我也在使用这两个库。

回答by openfrog

It's important to add this line in the php.ini:

在 php.ini 中添加这一行很重要:

xdebug.idekey="netbeans-xdebug"

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 中,转到“设置”并查看 xdebug 内容的设置位置。查找该会话 ID。就我而言,它是 netbeans-xdebug。

回答by deresh

hm, for me, the netbeans was the first ide that php debugging was working out of the box.

嗯,对我来说,netbeans 是第一个 php 调试开箱即用的 ide。

Does the xdebug show in phpinfo? if it does it should work with default settings. the only one that is needed is:

xdebug 是否显示在 phpinfo 中?如果是这样,它应该使用默认设置。唯一需要的是:

xdebug.remote_enable=on

So if this isn't enabled put it in your php.ini file, restart apache, and debugging should work.

因此,如果未启用此功能,请将其放入您的 php.ini 文件中,重新启动 apache,调试应该可以工作。

If not, you will have to supply more info for me to help you.

如果没有,您将不得不为我提供更多信息来帮助您。

sy

sy

回答by Derick Rethans

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.

xdebug 导致 curl 或 mod_rewrite 问题并不是已知问题。我知道的唯一问题是 Vista 上的 Xdebug。

回答by Rui

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

您可以在这里看到:http: //ruilima.com/2010/11/ambiente_de_desenvolvimento_php_netbeans_xdebug/是葡萄牙语,但有一个预配置的虚拟机,带有 Ubuntu 10.10、netbeans、php、mysql、xdebug,可以使用。看一看

回答by macio.Jun

If you are using xampp under Windows:

如果您在 Windows 下使用 xampp:

You only need to open your php.inifile and change these two lines

您只需要打开您的php.ini文件并更改这两行

;xdebug.profiler_enable = 0
;zend_extension = "C:\xampp\php\ext\php_xdebug.dll"

into

进入

xdebug.profiler_enable = 1
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"

(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)

(注意:如果你的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)

After that stop apache and start again, that's it.

之后停止apache并重新启动,就是这样。

回答by RaScoop

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.

我发现在 Netbeans 中,您需要将项目中的 webroot 路径设置为 app/webroot。如果你这样做,调试工作完美无缺。

回答by Danish Kayani

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

现在它在浪费了 3 个小时使 xdebug 在 Windows8 上工作后工作了,wamp 2.2 用以下内容替换了 [xdebug] 下面的原始行

    zend_extension = "c:/wamp/bin/php/php5.3.13/zend_ext/php_xdebug-2.2.0-5.3-vc9.dll"
    ;make sure path of your own php_xdebug, dll version may vary.

    [xdebug]

    xdebug.remote_enable = on
    xdebug.remote_handler=dbgp
    xdebug.remote_host=localhost
    xdebug.remote_port=9000
;recheck your port number in netbeans [Tools=>options=>php=>debugging there it is: debugging port]
    xdebug.profiler_enable = on
    xdebug.profiler_enable_trigger = on
    xdebug.profiler_output_name = cachegrind.out.%t.%p
    xdebug.profiler_output_dir = "c:/wamp/tmp"

Now click on wamp icon in taskbar and "restart all services"

现在单击任务栏中的 wamp 图标并“重新启动所有服务”

Well..Now final step>>START NETBEANS AS ADMINISTRATOR Holly soul of windows8 i hate you :<

好吧..现在最后一步>>以管理员身份启动 NETBEANS Windows8 的 Holly 灵魂我恨你 :<

回答by Krishna Chaitanya

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/

阅读以下文档以使用 NetBeans 进行远程调试。 http://stuporglue.org/setting-up-xdebug-with-netbeans-on-windows-with-a-remote-apache-server/

回答by Ian Lewis

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.

我偶尔会遇到 NetBeans 和 XDebug 问题,这些问题归结为存在与正在调试的代码无关的 Watch 语句。

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!

如果您发现这是导致您的问题的原因,请移除所有手表。一般来说,虽然我发现 XDebug 非常方便!

I do realise however that this may not relate to the issue you have here but it's worth being aware of.

但是,我确实意识到这可能与您在此处遇到的问题无关,但值得注意。