Launch XDebug in Netbeans by External Request

I use Netbeans 6.7 and XDebug to debug a PHP site on my machine by running a query from Netbeans (Project-> Debug). This works great and is very useful.

My question is: is it possible to attach a debugger to any request that comes in, and not to those that I run from Netbeans?

that is, instead of clicking Debug, put Netbeans in debugger startup mode and attach to the next request that comes in.

I have a feeling that this might be a stupid question, but if possible, it will be great.

Edit: A little more information

My system (Ubuntu 9.04) is configured as follows:

Contents /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 default debugging options:

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

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

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

But if I just go to http://www.mywebsite.com?XDEBUG_SESSION_START=netbeans-xdebug , this will not lead to a debugger in Netbeans.

I also tried setting xdebug.remote_host=www.mywebsite.com , but that doesn't make any difference.

Also, I turned on xdebug.remote_log and showed information when I start with netbeans, but nothing for external requests. Therefore, I do not think XDebug sees external requests at all.

+33
linux php xdebug netbeans
Oct 07 '09 at 12:40
source share
4 answers

go to project properties> perform configuration> advanced> debug url and check to not open web browser (*). do not install the host under the debugger proxy. save these settings. in the project window in your project: right click> debug (this starts listening for debugging connections). the browser does not start. enter http://www.mywebsite.com?XDEBUG_SESSION_START=netbeans-xdebug in your browser. he must break into netbeans. at least what happens here :)

(*) You may also need to set the path display - for me, this works without

+40
Oct 9 '09 at 16:15
source share

By default, xdebug will not attempt to connect to the remote host unless the Cookie / URL parameter XDEBUG_SESSION_START is specified. You can enable xdebug for "always on" by setting xdebug.remote_autostart to 1 in php.ini.

In addition, for this you will need to run the PHP debugger in NetBeans. I haven't found a better solution yet, but you can get the PHP debugger to listen for incoming connections by starting to debug a random file (use CTRL + SHIFT + F5 to start debugging the file) and then continue (by pressing F5) once it stops at the breakpoint. The Netbeans debugger should work until you stop it.

Update: Due to NetBeans checking the session identifier (XDEBUG_SESSION_START), you must also set the idekey variable. eg:

 xdebug.remote_autostart = 1 xdebug.idekey = "netbeans-xdebug" 
+17
May 17 '10 at 16:31
source share

I had a similar problem (on NetBeans, Mac OSX) after updating PHP and compiling / installing xdebug. phpinfo showed xdebug as loaded, but it still won’t connect, and after all of the above, it still fails. Then I tried to reduce the number of parameters set in my PHP.ini file to the minimum necessary. It seemed to me that this is a problem.

 ; REMOVED (commented) the following ; xdebug.remote_log=/myfile.log ;xdebug.extended_info = off ;xdebug.auto_trace=1 ;xdebug.trace_output_dir=/mydir/myphptracefile.txt ;xdebug.trace_output_name=php_trace.%c ;xdebug.collect_params=4 

I also renamed the default xdebug.idekey from netbeans-xdebug to the default and then again.

After restarting Apache, xdebug started working again: I'm not sure what it was fixed, but a good starting point can only be the beginning with the minimum number of xdebug settings in your php.ini file, then slowly add more if you need them. I suspect that this may have had something to do with the trace settings, but cannot be sure.

The main settings that I used were:

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

It's also nice to compile debugclient (in the original xdebug package) and check debugging on the command line, as this will tell you if xdebug can work at least regardless of your IDE.

+1
Jul 18 '14 at 9:56
source share

Not sure about Netbeans, but any other IDE I used always listens for a debugging connection. You can start a new debugging session from xdebug by adding the query string ?XDEBUG_SESSION_START=name to url. If Netbeans is listening, this should start with a new debugging session.

See http://xdebug.org/docs/remote#browser_session for details

0
Oct 08 '09 at 22:04
source share



All Articles