Xdebug 2.0.3 – Stealth Patch

On PHP conferences or user group meetings one question that pops up again and again is why Xdebug and some other commercial PHP extensions e.g. Zend Debugger cannot be loaded at the same time. Those asking usually can understand why running two debuggers at the same time will lead to problems, but they don’t understand why problems should arise when only one is used at a time. They want to be able to load Zend Debugger and Xdebug with the same php.ini without the need to restart the whole server just to change the debugger. Because of this people requested repeatedly that I port the stealth magic that I perform in Suhosin to Xdebug to be able to load both debuggers at the same time.

You can download the patch against Xdebug 2.0.3 at:

https://www.suspek.org/downloads/xdebug-2.0.3-stealth.diff.gz

Keep in mind that in order to become stealth you must load xdebug like a normal PHP extension with:

extension=xdebug.so

You cannot load it as zend_extension because otherwise the “protection” of the commercial tools will kick in. However when loaded as normal PHP extension Xdebug will register itself as Zend Extension and should function normally.

Attention: I don’t use this patch myself so if you encounter any problem contact me so that I can fix it.

Update: The patch was updated because there was a crash on process termination when stealth mode was not needed. In the comments it is reported that Xdebug still works partially while Zend Debugger is activated.