composer / composer/xdebug-handler
PHP binary path hardcoded
- Dominant language
- PHP
- Stars
- 2.6k
- Forks
- 33
- Avg merge
- 6h 46m
- Merged PRs (30d)
- 1
Description
Would it be possible to be able to override path to PHP binary inside this handler, please? Maybe using some ENV variable?
I am using wrapper for PHP 8.5 under WSL1, so PHP_BINARY constant does not return wrapper, but original binary. Therefore I get this error when running composer under PHP 8.5 with Xdebug enabled:
```
PHP Warning: proc_open(): posix_spawn() failed: Exec format error in phar:///usr/local/bin/composer/vendor/composer/xdebug-handler/src/XdebugHandler.php on line 300
PHP Stack trace:
PHP 1. {main}() /usr/local/bin/composer:0
PHP 2. require() /usr/local/bin/composer:29
PHP 3. Composer\XdebugHandler\XdebugHandler->check() phar:///usr/local/bin/composer/bin/composer:43
PHP 4. Composer\XdebugHandler\XdebugHandler->restart($command = [0 => '/usr/bin/php8.5-bin', 1 => '-n', 2 => '-c', 3 => '/tmp/fh3d7t9hgapgdGR3Iik', 4 => '/usr/local/bin/composer']) phar:///usr/local/bin/composer/vendor/composer/xdebug-handler/src/XdebugHandler.php:149
PHP 5. Composer\XdebugHandler\XdebugHandler->doRestart($command = [0 => '/usr/bin/php8.5-bin', 1 => '-n', 2 => '-c', 3 => '/tmp/fh3d7t9hgapgdGR3Iik', 4 => '/usr/local/bin/composer']) phar:///usr/local/bin/composer/vendor/composer/xdebug-handler/src/XdebugHandler.php:274
PHP 6. proc_open($command = [0 => '/usr/bin/php8.5-bin', 1 => '-n', 2 => '-c', 3 => '/tmp/fh3d7t9hgapgdGR3Iik', 4 => '/usr/local/bin/composer'], $descriptor_spec = [], $pipes = NULL) phar:///usr/local/bin/composer/vendor/composer/xdebug-handler/src/XdebugHandler.php:300
```
It would be nice if path to PHP binary could be specified manually here.
Here is relevant part:
https://github.com/composer/xdebug-handler/blob/main/src/XdebugHandler.php#L438
Instead of:
```
$php = [PHP_BINARY];
```
Maybe something like:
```
$php = [getenv('PHP_BINARY') ?: PHP_BINARY];
```
Or some other solution...?
Thanks!
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/XdebugHandler.php around line 438, where the restart command selects PHP_BINARY, and trace how that value reaches the process restart. Define and document the override behavior, including the fallback when no override is provided, then verify that the configured binary is used for the restarted command.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100