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

Tried for quite some time to get it working correctly, but 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 the debugging code called by the SimpleTest unit tests. SimpleTest can clearly see XDebug, because I can generate code coverage reports, but it just won't stop at breakpoints.

Edit : It should be added that XDebug and breakpoints work fine in eclipse, not when calling SimpleTest

Has anyone installed this successfully? There are a lot of gaff documents and a little useful information.

Thanks!

+6
debugging eclipse php xdebug simpletest
source share
2 answers

Make sure you have the correct XDebug version for your version of PHP and add it 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 run apachectl graceful and a phpinfo and make sure XDebug is present and active. If so, everything should work fine. I know this is for me.

edit: I answered before reading the whole question.

Before running the script, you must set the environment variable;

 export XDEBUG_CONFIG="idekey=session_name" 

It may be possible to do this from php, but I cannot verify this:

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

You have to make sure that the php binary you are using contains the XDebug extension, there is an apache module on my system, but the CLI interpreter does not do this by default, but I run different versions on purpose.

There is good documentation here

+3
source share

To continue Chris’s response, if you are managing the production and development environment on the same server, it is recommended to cancel the xdebug settings on either php include or those specified in virtualhosts that are allocated in dev or testing environments:

  • The syntax for virtualhosts is

     <virtualHost ....> (...) # Xdebug ENV php_flag xdebug.auto_trace on php_flag xdebug.idekey session_name php_flag xdebug.profiler_enable_trigger 1 php_flag xdebug.(...) (...) 
0
source share

All Articles