Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you set-up PHP + xDebug + (x)Unit + Eclipse to work with breakpoints in unit tests?

Have tried for quite some time to get this to work correctly but to no luck. Basically, I have Eclipse (3.3) with PHP Development Tools (PDT), and the PDT XDebug plugin as well as the SimpleTest eclipse plugin.

What I want to do is debug code invoked by SimpleTest unit tests. SimpleTest clearly can see XDebug, because I can generate code coverage reports, but it just won't stop on breakpoints.

Edit: Should add that XDebug and breakpoints work fine in eclipse, just not when invoked by SimpleTest

Has anyone set this up successfully? There's a lot of guff docs around and little in the way of useful information.

Thanks!

like image 897
spronkey Avatar asked May 19 '09 00:05

spronkey


1 Answers

Make sure you have the right XDebug version for your version of PHP and add this at the very beginning of your php.ini file:

[xdebug]
zend_extension=full_path_to_your_xdebug.so 
xdebug.default_enable=On
xdebug.remote_enable=On
xdebug.remote_handler="dbgp"
xdebug.remote_host="localhost"
xdebug.remote_port=9000

Then do an apachectl graceful and a phpinfo and make sure XDebug is present and active. If it is, everything should work fine. I know it does for me.

edit: I answered before reading the entire question.

before running the script you should set the environment variable;

export XDEBUG_CONFIG="idekey=session_name"

It might be possible to do this from php but i cannot test this:

putenv('XDEBUG_CONFIG="idekey=session_name"');

You should make sure that the php binary you are using has the XDebug extension loaded, on my system the apache module has it, but the default CLI interpreter does not, but I run different versions on purpose.

There's some good documentation here

like image 79
3 revs Avatar answered Sep 30 '22 05:09

3 revs