From fbbde23fb3b30839baaeb23c9a002eca8ea56122 Mon Sep 17 00:00:00 2001 From: Niels Keurentjes Date: Tue, 8 Mar 2016 23:09:08 +0100 Subject: [PATCH] Improved error message when adding a package that is disallowed by PHP version, fixes #4686 --- src/Composer/Command/InitCommand.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index a43f67768..c352b1829 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -633,6 +633,12 @@ EOT $package = $versionSelector->findBestCandidate($name, null, $phpVersion); if (!$package) { + // Check whether the PHP version was the problem + if ($phpVersion && $versionSelector->findBestCandidate($name)) { + throw new \InvalidArgumentException(sprintf( + 'Could not find package %s at any version matching your PHP version %s', $name, $phpVersion + )); + } throw new \InvalidArgumentException(sprintf( 'Could not find package %s at any version for your minimum-stability (%s). Check the package spelling or your minimum-stability', $name,