Last active
March 13, 2022 15:50
-
-
Save guillemcanal/92f4a97bb31d25522a9a7658a5ff5019 to your computer and use it in GitHub Desktop.
Scripts using the XdebugHandler componant will load PHP extensions twice on a Nix environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require __DIR__ . '/vendor/autoload.php'; | |
// Most PHP CLI tools run this snippet to disable Xdebug at runtime | |
use Composer\XdebugHandler\XdebugHandler; | |
$xdebug = new XdebugHandler('myCliApp'); | |
$xdebug->setPersistent(); | |
$xdebug->check(); | |
unset($xdebug); | |
// This will contains the ini script created by XdebugHandler without the xdebug extension | |
echo 'PHPRC: ', getenv('PHPRC'), PHP_EOL; | |
// This should be empty, but on a Nix environment, the PHP binary is wrapped in a bash script | |
// which export PHP_INI_SCAN_DIR with a fixed value and then run the actual PHP binary with the exec command. | |
// Consequently, PHP extensions are loaded twice. | |
echo 'PHP Scan Dir : ', getenv('PHP_INI_SCAN_DIR'), PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To quickly reproduce the issue:
With XDebug extension
composer.json
containing arequire
section as such:composer install
:wget https://gist.githubusercontent.com/guillemcanal/92f4a97bb31d25522a9a7658a5ff5019/raw/563e406374eed3d2994f9118d6ed381ab1ac721c/xdebug-handler-nix-boom.php
php xdebug-handler-nix-boom.php
Without XDebug extension
composer install
:wget https://gist.githubusercontent.com/guillemcanal/92f4a97bb31d25522a9a7658a5ff5019/raw/563e406374eed3d2994f9118d6ed381ab1ac721c/xdebug-handler-nix-boom.php
php xdebug-handler-nix-boom.php