views:

122

answers:

3

Hi all,

I installed xdebug on my Apache and if I define a breakpoint in Netbeans, the execution breaks fine. But if I execute the tests with symfony phpunit:test-all, the execution will not break on the given break point.

Any ideas? cowabunga!

A: 

When you say you define a breakpoint in Netbeans and it breaks fine, are you talking about running the unit tests from within Netbeans, or running a web application that triggers the breakpoints in Netbeans?

Either way, my first guess would be that the two scenarios are using different PHP.INI files. Get one of your unit tests to dump configuration information and you'll see pretty quickly I daresay. Find the PHP.INI that's being used on the command line and make sure that XDebug is set up for that scenario.

I hope that makes sense. I'm entirely coffee-free at the moment.

Narcissus
I run a web application that triggers the breakpoints in Netbeans.If I run @php -i@, I see that xdebug support is enabled, therefore I think xdebug is configured well in command line.
cowabunga1984
Cool. One thing you could try is adding xdebug.remote_autostart=1 to the [xdebug] section of your PHP.INI file. The problem could be related to the CLI not pushing the appropriate XDebug cookie / GET parameter to actually trigger it. If that doesn't work, be sure to check your other xdebug settings in PHP.INI.
Narcissus
I tried some configurations but nothing works. Maybe it does not work because I use the ZendServer. In the Xdebug documentation I can read, that the a combination of zend optimizer and xdebug can lead to compatibility problems. ATM I think I should retry to configure xdebug if I installed XAMPP or another server...
cowabunga1984
Hmmm... How can I see wheter xdebug is installed correctly? I typed @php -i@ and I see that xdebug is activated, but if I call var_dump, the output is not "pimped"?!?
cowabunga1984
Yeah, Zend Optimizer and XDebug together could be the problem: loading more than one 'zend_extension' used to be an issue, at least. As far as telling if XDebug is installed correctly, you could always try calling an XDebug specific function, eg. xdebug_get_declared_vars().
Narcissus
I can call xdebug_get_declared_vars. It seems to be installed correcty...
cowabunga1984
Sorry mate... all out of ideas then right now :s
Narcissus
A: 

I don't use netbeans but I don't think netbeans modifies the file you put break points in and I don't think that symfony can read your netbean configuration to find out where to break.

Also if you are running the test all task inside netbeans and expect the test files to break I don't think that will work either as the task forks php processes I believe and these processes won't be readable by netbeans.

All hypothesis of course.

johnwards
I think, that the xdebug waits for connections on the configured port (9000). If I run the tests, xdebug has to wait and Netbeans has to connect to xdebug (with the given port). After that, Netbeans configures the breakpoints and the tests should break as expected...Thats why I think that it should work, event if the processes are forked.
cowabunga1984
A: 

To debug a command-line script, export the XDEBUG_CONFIG variable first, like so:

export XDEBUG_CONFIG="idekey=netbeans-xdebug" (Unix/Linux/OS X)

set XDEBUG_CONFIG=idekey=netbeans-xdebug (Windows)

(Note: I did not test the Windows command. You may have to escape the = character, or the command may look a bit different. If that's the case, I hope someone comes along and corrects me in a comment.)

Explanation: When you open a debugging session for a script that runs through Apache, NetBeans will open your browser to a URL that ends with "XDEBUG_SESSION_START=netbeans-xdebug". When this happens, Xdebug knows to intercept this argument and give your browser a cookie with this debug session information.

The command above is the equivalent for setting the cookie in the command line environment.

i-g