Description
Disclaimer: I'm using
mbstring
as an example here, but this applies to any extension.
When a package requires ext-mbstring
and you don't have it, the output currently looks like that:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires PHP extension ext-mbstring * but it is missing from your system. Install or enable PHP's mbstring extension.
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/8.2/cli/php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-mbstring` to temporarily ignore these required extensions.
Installing the mbstring extension is indeed the best solution in term of performance. However, there is another alternative if you cannot install the extension: installing a polyfill package that provides the API implemented in PHP. For instance, symfony/polyfill-mbstring
provides it for ext-mbstring
.
The providers-api-url of Packagist works fine for those extension packages. For instance, the list of packages providing ext-mbstring
is at https://packagist.org/providers/ext-mbstring.json
So it would be great if Composer could load it and display an alternative solution based on installing a polyfill package.