根据外部请求在 Netbeans 中启动 XDebug

时间:2023-04-09
本文介绍了根据外部请求在 Netbeans 中启动 XDebug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在使用 Netbeans 6.7 和 XDebug 在我的机器上调试 PHP 站点,从 Netbeans 内启动请求(项目->调试).这很好用,而且非常有用.

I'm using Netbeans 6.7 and XDebug to debug a PHP site on my machine, launching the request from within Netbeans (Project->Debug). This works fine, and is very useful.

我的问题是:是否可以将调试器附加到任何传入的请求中,而不仅仅是我从 Netbeans 中启动的请求?

My question is: Is it possible to attach the debugger to any request that comes in, rather just those I launch from within Netbeans?

即,不是单击调试",而是将 Netbeans 置于启动调试器并附加到进入的下一个请求的模式中.

ie, instead of clicking "Debug", put Netbeans into a mode whereby the debugger is launched and attaches to the next request that comes in.

我觉得这可能是一个愚蠢的问题,但如果可能的话,那就太好了.

I have a feeling this may be a stupid question, but if it is possible, that'd be great.

更多信息

我的系统(Ubuntu 9.04)设置如下:

My system (Ubuntu 9.04) is set up as follows:

/etc/php5/conf.d/xdebug.ini的内容

zend_extension=/usr/lib/php5/20060613/xdebug.so

xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey=netbeans-xdebug

Netbeans PHP 调试选项为默认值:

Netbeans PHP debugging options are at the defaults:

Debugger Port: 9000
Session ID: netbeans-xdebug
Stop at the First Line: ticked

我的 /etc/hosts 文件将 www.mywebsite.com 重定向到 localhost

My /etc/hosts file redirects www.mywebsite.com to localhost

如果我单击 Netbeans 中的调试按钮,Firefox 将使用地址 http://www.mywebsite.com?XDEBUG_SESSION_START=netbeans-xdebug 启动,并且调试器按预期工作.

If I click on the debug button in Netbeans, then Firefox is launched with the address http://www.mywebsite.com?XDEBUG_SESSION_START=netbeans-xdebug, and the debugger works as expected.

但如果我只是浏览到 http://www.mywebsite.com?XDEBUG_SESSION_START=netbeans-xdebug,这不会在 Netbeans 中启动调试器.

But if I just browse to http://www.mywebsite.com?XDEBUG_SESSION_START=netbeans-xdebug, this doesn't start the debugger in Netbeans.

我也试过设置 xdebug.remote_host=www.mywebsite.com ,但这没什么区别.

I've also tried setting xdebug.remote_host=www.mywebsite.com , but that makes no difference.

此外,我已经启用了 xdebug.remote_log,它显示了我从 netbeans 内部启动时的信息,但没有显示外部请求的信息.所以我认为 XDebug 根本没有看到外部请求.

Also, I've enabled xdebug.remote_log, and that's showing information for when I start from within netbeans, but nothing for external requests. So I don't think XDebug is seeing the external requests at all.

推荐答案

转到项目属性 > 运行配置 > 高级 > 调试网址并检查不要打开网络浏览器 (*).不要调试器代理下设置主机.保存这些设置.在项目窗口中,在您的项目上:鼠标右键单击 > 调试(这将开始侦听调试连接).没有启动浏览器.在浏览器中输入 http://www.mywebsite.com?XDEBUG_SESSION_START=netbeans-xdebug.它应该在 netbeans 中崩溃.至少这就是这里发生的事情:)

go to project properties > run configuration > advanced > debug url and check do not open web browser (*). do not set the host under debugger proxy. save these settings. in the project window, on your project: right mouse click > debug (this starts listening for debug connections). no browser is started. enter http://www.mywebsite.com?XDEBUG_SESSION_START=netbeans-xdebug in your browser. it should break in netbeans. at least that's what happens here :)

(*) 你可能还需要设置一个路径映射 - 对我来说,它不需要

(*) you might also have to set a path mapping - for me, it works without

这篇关于根据外部请求在 Netbeans 中启动 XDebug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:Xdebug 成功连接到 DBGP 客户端,但不会在断点处停止 下一篇:如何使用 netbeans 和 Xdebug 调试 PHP

相关文章