You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
XdebugHandler->check() should be called very early #175
I did some testing with xdebug-handler. my test.php looks like
<?phpuseComposer\XdebugHandler\XdebugHandler;
require_once__DIR__ . '/vendor/autoload.php';
var_dump(extension_loaded('xdebug'));
echo"booting a second...\n";
sleep(1);
$xdebug = newXdebugHandler('myapp');
$xdebug->check();
unset($xdebug);
var_dump(extension_loaded('xdebug'));
echo"running a second...\n";
sleep(1);
what I realized is, that the logic which is running before $xdebug->check(); is executed twice.
➜ xdebug-handler git:(pcntl_exec) ✗ php test.php
bool(true)
booting a second...
bool(false)
booting a second...
bool(false)
running a second...
this means a application should invoke $xdebug->check(); very very early in the process, because the bootstrap logic is executed twice in the restarting case.
what I realized is, that the logic which is running before $xdebug->check(); is executed twice.
Err, well yes, it would have to.
this means a application should invoke $xdebug->check(); very very early in the process,
It depends what the application wants to do though and whether it needs certain information before it can decide. The readme contains a simplified example which does not restart on a help command https://github.com/composer/xdebug-handler#example
It also points to some Examples that are used in the functional tests but can also be run independently to illustrate the behaviour in different scenarios. So you could use app-basic.php instead of your test script:
cd tests/App
php app-basic.php --display
app-basic[7672] start
logger[7672] Checking APP_BASIC_ALLOW_XDEBUG
logger[7672] The Xdebug extension is loaded (3.5.3) xdebug.mode=coverage
logger[7672] Process restarting (APP_BASIC_ALLOW_XDEBUG=internal|3.5.3|0|*|*)
logger[7672] Running: [C:\php-8.4.26\php.exe, -n, -c, C:\***\Local\Temp\suh2CE2.tmp, app-basic.php]
app-basic[2784] start
logger[2784] Checking APP_BASIC_ALLOW_XDEBUG
logger[2784] Restarted (129 ms). The Xdebug extension is not loaded
app-basic[2784] working [NO XDEBUG] The Xdebug extension is not loaded
app-basic[2784] working [active] false
app-basic[2784] working [skipped] 3.5.3
app-basic[2784] working [env] PHPRC unset
app-basic[2784] working [env] PHP_INI_SCAN_DIR unset
app-basic[2784] working [ini] C:\php-8.4.26\php.ini
app-basic[2784] working [settings] tmpIni=C:\***\Local\Temp\suh2CE2.tmp
app-basic[2784] working [settings] scannedInis=false
app-basic[2784] working [settings] scanDir=false
app-basic[2784] working [settings] phprc=false
app-basic[2784] working [settings] inis=C:\php-8.4.26\php.ini
app-basic[2784] working [settings] skipped=3.5.3
app-basic[2784] finish
logger[7672] Restarted process exited 0
Activity
[-]`XdebugHandler->check()` should be verify early[/-][+]`XdebugHandler->check()` should be called very early[/+]johnstevenson commentedon Oct 18, 2026
Err, well yes, it would have to.
It depends what the application wants to do though and whether it needs certain information before it can decide. The readme contains a simplified example which does not restart on a help command https://github.com/composer/xdebug-handler#example
It also points to some Examples that are used in the functional tests but can also be run independently to illustrate the behaviour in different scenarios. So you could use
app-basic.phpinstead of your test script: