A PHP debugger extension focused on step debugging with near-zero overhead. Forked from Xdebug, with profiling, coverage, and tracing removed.
Note
π§ͺ This project is an experiment exploring minimal-overhead PHP debugging.
- Near-zero overhead when loaded but no debug client is connected
- Xdebug-compatible β existing configs, IDE setups, and workflows work unchanged
- Debug-only β focused exclusively on step debugging
- Full DBGp protocol support β works with PhpStorm, VS Code, and any DBGp-compatible IDE
The following benchmarks were run in GitHub's CI (GitHub Actions) environment using a standard Ubuntu runner. The performance was measured using Valgrind to count the number of executed instructions. This is much more precise and reproducible than timing execution runs. All measuremments were done using all supported PHP versions (the number shown is the average), with the extension loaded and no IDE connected.
We measured three different scenarios which we believe represent a good mix of typical PHP operations:
bench.php: a syntetic benchmark that runs a number of computationally heavy functions
| Configuration | Overhead |
|---|---|
| No debugger | β |
| Xdebug | +661.6% |
| PHP Debugger | +12.9% |
Rector: running a RectorPHP rule on a PHP file
| Configuration | Overhead |
|---|---|
| No debugger | β |
| Xdebug | +124.5% |
| PHP Debugger | +3.6% |
Symfony: running a basic request on a Symfony demo project
| Configuration | Overhead |
|---|---|
| No debugger | β |
| Xdebug | +35.3% |
| PHP Debugger | +1.3% |
To improve the performance of code running with the PHP Debugger enabled, several features required for on-demand debugging are disabled if the debugger does not connect to a client at startup.
On-demand debugging allows the debugger to connect later during executionβfor example, via xdebug_connect_to_client(),
xdebug_break(), or when an error or exception occurs.
We consider on-demand debugging to be a relatively uncommon use case, and we want to avoid degrading performance for the majority of users. However, since some users rely on this functionality, we provide an INI setting to enable it when needed.
INI setting: php_debugger.on_demand_debugging_enabled (default: false)
When this setting is enabled, on-demand debugging features remain active even if no client is connected at startup. Note that this has a significant performance impact: instead of achieving up to a 97% performance improvement, the average improvement drops to around 60%.
For this reason, we recommend enabling this setting only if you specifically require on-demand debugging.
Grab the right binary from Releases, copy it to your extension directory, and add to php.ini:
zend_extension=php_debugger.soQuick install script:
curl -fsSL https://raw.githubusercontent.com/php-debugger/php-debugger/main/install.php | phpPIE (PHP Installer for Extensions):
pie install php-debugger/php-debuggerPHP Debugger accepts both php_debugger.* and xdebug.* INI prefixes. Existing Xdebug configurations work as-is.
; Both of these work:
php_debugger.mode = debug
php_debugger.client_host = 127.0.0.1
php_debugger.client_port = 9003
php_debugger.start_with_request = trigger
; Xdebug-compatible (also works):
xdebug.mode = debug
xdebug.client_host = 127.0.0.1
xdebug.client_port = 9003
xdebug.start_with_request = triggerWorks with existing PhpStorm debug configurations. No IDE changes needed.
Configuring Debugger in PhpStorm
Works as-is. No changes needed.
PHP Debugger maintains compatibility with Xdebug's debug mode:
| Feature | PHP Debugger | Xdebug |
|---|---|---|
extension_loaded("xdebug") |
β true | β true |
extension_loaded("php_debugger") |
β true | β false |
xdebug.* INI settings |
β works | β works |
xdebug_break() |
β works | β works |
XDEBUG_SESSION trigger |
β works | β works |
| Step debugging (DBGp) | β | β |
| On-demand debugging | β
works if on_demand_debugging_enabledis set, does not work otherwise |
β |
| Code coverage | β use pcov | β |
| Profiling | β removed | β |
| Tracing | β removed | β |
You can also use the new names β they work alongside the Xdebug ones:
- INI:
php_debugger.mode,php_debugger.client_host, etc. - Functions:
php_debugger_break(),php_debugger_info(),php_debugger_connect_to_client(),php_debugger_is_debugger_active(),php_debugger_notify() - Triggers:
PHP_DEBUGGER_SESSION,PHP_DEBUGGER_SESSION_START,PHP_DEBUGGER_TRIGGER
- PHP 8.2, 8.3, 8.4, or 8.5
Released under The Xdebug License, version 1.03 (based on The PHP License).
This product includes Xdebug software, freely available from https://xdebug.org/.
PHP Debugger is built on the foundation of Xdebug, created and maintained by Derick Rethans since 2002. His two decades of work on PHP debugging tools made this project possible. Thank you, Derick.