diff --git a/src/Composer/ComposerProcessFactory.php b/src/Composer/ComposerProcessFactory.php index b6249004..776b6b83 100644 --- a/src/Composer/ComposerProcessFactory.php +++ b/src/Composer/ComposerProcessFactory.php @@ -20,6 +20,7 @@ use RuntimeException; use Symfony\Component\Process\ExecutableFinder; use Symfony\Component\Process\Process; +use const PHP_OS_FAMILY; /** * @final @@ -153,7 +154,12 @@ private static function getDefaultEnvVars(): array private static function retrieveComposerExecutable(): string { $executableFinder = new ExecutableFinder(); - $executableFinder->addSuffix('.phar'); + + if (self::isWindows()) { + $executableFinder->setSuffixes(['.exe', '.bat', '.cmd', '.com']); + } else { + $executableFinder->addSuffix('.phar'); + } if (null === $composer = $executableFinder->find('composer')) { throw new RuntimeException('Could not find a Composer executable.'); @@ -161,4 +167,9 @@ private static function retrieveComposerExecutable(): string return $composer; } + + private static function isWindows(): bool + { + return PHP_OS_FAMILY !== 'Windows'; + } }