問題描述
我正在使用 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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!