Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
356 views
in Technique[技术] by (71.8m points)

php - Launch XDebug in Netbeans on an external request

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.

My question is: Is it possible to attach the debugger to any request that comes in, rather just those I launch from within 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.

Edit: A bit more information

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

Contents of /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 debugging options are at the defaults:

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

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

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.

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

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...