問(wèn)題描述
我正在使用 Netbeans 6.7 和 XDebug 在我的機(jī)器上調(diào)試 PHP 站點(diǎn),從 Netbeans 內(nèi)啟動(dòng)請(qǐng)求(項(xiàng)目->調(diào)試).這很好用,而且非常有用.
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.
我的問(wèn)題是:是否可以將調(diào)試器附加到任何傳入的請(qǐng)求中,而不僅僅是我從 Netbeans 中啟動(dòng)的請(qǐng)求?
My question is: Is it possible to attach the debugger to any request that comes in, rather just those I launch from within Netbeans?
即,不是單擊調(diào)試",而是將 Netbeans 置于啟動(dòng)調(diào)試器并附加到進(jìn)入的下一個(gè)請(qǐng)求的模式中.
ie, instead of clicking "Debug", put Netbeans into a mode whereby the debugger is launched and attaches to the next request that comes in.
我覺(jué)得這可能是一個(gè)愚蠢的問(wèn)題,但如果可能的話,那就太好了.
I have a feeling this may be a stupid question, but if it is possible, that'd be great.
更多信息
我的系統(tǒng)(Ubuntu 9.04)設(shè)置如下:
My system (Ubuntu 9.04) is set up as follows:
/etc/php5/conf.d/xdebug.ini
的內(nèi)容
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 調(diào)試選項(xiàng)為默認(rèn)值:
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 中的調(diào)試按鈕,F(xiàn)irefox 將使用地址 http://www.mywebsite.com?XDEBUG_SESSION_START=netbeans-xdebug
啟動(dòng),并且調(diào)試器按預(yù)期工作.
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
,這不會(huì)在 Netbeans 中啟動(dòng)調(diào)試器.
But if I just browse to http://www.mywebsite.com?XDEBUG_SESSION_START=netbeans-xdebug
, this doesn't start the debugger in Netbeans.
我也試過(guò)設(shè)置 xdebug.remote_host=www.mywebsite.com
,但這沒(méi)什么區(qū)別.
I've also tried setting xdebug.remote_host=www.mywebsite.com
, but that makes no difference.
此外,我已經(jīng)啟用了 xdebug.remote_log
,它顯示了我從 netbeans 內(nèi)部啟動(dòng)時(shí)的信息,但沒(méi)有顯示外部請(qǐng)求的信息.所以我認(rèn)為 XDebug 根本沒(méi)有看到外部請(qǐng)求.
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.
推薦答案
轉(zhuǎn)到項(xiàng)目屬性 > 運(yùn)行配置 > 高級(jí) > 調(diào)試網(wǎng)址并檢查不要打開(kāi)網(wǎng)絡(luò)瀏覽器 (*).不要在調(diào)試器代理下設(shè)置主機(jī).保存這些設(shè)置.在項(xiàng)目窗口中,在您的項(xiàng)目上:鼠標(biāo)右鍵單擊 > 調(diào)試(這將開(kāi)始偵聽(tīng)調(diào)試連接).沒(méi)有啟動(dòng)瀏覽器.在瀏覽器中輸入 http://www.mywebsite.com?XDEBUG_SESSION_START=netbeans-xdebug
.它應(yīng)該在 netbeans 中崩潰.至少這就是這里發(fā)生的事情:)
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 :)
(*) 你可能還需要設(shè)置一個(gè)路徑映射 - 對(duì)我來(lái)說(shuō),它不需要
(*) you might also have to set a path mapping - for me, it works without
這篇關(guān)于根據(jù)外部請(qǐng)求在 Netbeans 中啟動(dòng) XDebug的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!