Skip to content

Improve error message when a package is not found and suggest package name #264

@GromNaN

Description

@GromNaN

When migrating from pecl to pie, it's tempting to try to install the same package name, which obviously fails since extension names have a vendor prefix.

❯ pie install mongodb
🥧 PHP Installer for Extensions (PIE) 1.0.0, from The PHP Foundation
This command may need elevated privileges, and may prompt you for your password.
You are running PHP 8.4.6
Target PHP installation: 8.4.6 nts, on Linux/OSX/etc arm64 (from /opt/homebrew/Cellar/php/8.4.6/bin/php)

In UnableToResolveRequirement.php line 25:

  Unable to find an installable package mongodb for the latest compatible version, with minimum stability stable.


install [-j|--make-parallel-jobs MAKE-PARALLEL-JOBS] [--skip-enable-extension] [--force] [-d|--working-dir WORKING-DIR] [--with-php-config WITH-PHP-CONFIG] [--with-php-path WITH-PHP-PATH] [--with-phpize-path WITH-PHPIZE-PATH] [--] [<requested-package-and-version>]

I find the error message a bit crude. It could be improved in the following ways:

  • Do not mention the file where the error occurred. This is not relevant to the user.
  • Do not list the command options, as the command was called correctly. This can be resolved by catching the specific exception and displaying an error message instead of relying on the native behavior of symfony/console.
  • Suggest the name of the extension to install. Packagist has information on which extension implements mongodb as this is displayed when installing from the correct package name.
❯ pie install mongodb/mongodb-extension
🥧 PHP Installer for Extensions (PIE) 1.0.0, from The PHP Foundation
This command may need elevated privileges, and may prompt you for your password.
You are running PHP 8.4.6
Target PHP installation: 8.4.6 nts, on Linux/OSX/etc arm64 (from /opt/homebrew/Cellar/php/8.4.6/bin/php)
Found package: mongodb/mongodb-extension:2.1.1 which provides ext-mongodb
Found prebuilt archive: https://github.com/mongodb/mongo-php-driver/releases/download/2.1.1/mongodb-2.1.1.tgz

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestmaintainer investigatingThis ticket is being investigated by maintainers. Please check with us before contributing PRs etc!

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions