diff --git a/src/Composer/Installer/BinaryInstaller.php b/src/Composer/Installer/BinaryInstaller.php index 43254af61f5e..91479bf58ced 100644 --- a/src/Composer/Installer/BinaryInstaller.php +++ b/src/Composer/Installer/BinaryInstaller.php @@ -359,6 +359,11 @@ public function url_stat(\$path, \$flags) $globalsCode $streamProxyCode + +if (__FILE__ === realpath(\$_SERVER['SCRIPT_NAME'])) { + \$_SERVER['SCRIPT_NAME'] = realpath($binPathExported); +} + return include $binPathExported; PROXY; diff --git a/tests/Composer/Test/Installer/BinaryInstallerTest.php b/tests/Composer/Test/Installer/BinaryInstallerTest.php index 8b6d472435e1..0fe971793e5b 100644 --- a/tests/Composer/Test/Installer/BinaryInstallerTest.php +++ b/tests/Composer/Test/Installer/BinaryInstallerTest.php @@ -110,6 +110,18 @@ public static function executableBinaryProvider(): array [<<<'EOL' +