Restarts CLI processes without loading the Xdebug extension to improve performance.
Composer Xdebug Handler is a PHP library that automatically restarts command-line interface (CLI) processes without loading the Xdebug extension, unless it's explicitly disabled. It solves the performance overhead of Xdebug during routine tasks like dependency management by transparently restarting processes in an Xdebug-free environment. Originally part of Composer, it is now a standalone tool for seamless integration into PHP CLI applications.
PHP developers working with command-line tools or scripts that need to avoid Xdebug's performance impact during non-debugging operations, such as running Composer, PHPUnit, or other CLI-based utilities. It is particularly useful for tool maintainers who want to ensure their applications run efficiently without requiring users to manually disable Xdebug.
Developers choose this library because it automatically handles the restart process transparently, eliminating the need for manual configuration or user intervention. Its unique selling point is the ability to keep Xdebug available for debugging while avoiding its slowdown in everyday CLI tasks, with extensible design for custom restart logic and support for persistent settings across sub-processes.
Restart a CLI process without loading the xdebug extension.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Transparently restarts CLI processes without Xdebug to avoid slowdowns, using environment variables like MYAPP_ALLOW_XDEBUG for control, as shown in the Basic Usage section.
Offers protected methods like requiresRestart() and restart() for custom modifications, such as adjusting ini settings like phar.readonly, demonstrated in the Extending the library example.
Provides static utilities like getAllIniFiles() and getRestartSettings() to access original configurations in restarted processes, detailed in the Helper methods section.
Includes built-in support for asynchronous signals (e.g., SIGINT) and Windows control events, ensuring clean process management as described in the Signal handling subsection.
Extensions specified via command-line arguments are not loaded in restarted processes, a admitted limitation in the README that can break tools relying on them.
Extending the library for custom logic requires overriding protected methods and careful parent calls, increasing development overhead compared to simpler solutions.
Restarts can fail if temporary ini files cannot be created, necessitating troubleshooting with XDEBUG_HANDLER_DEBUG, as shown in the logging examples, which adds uncertainty.