-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Is your feature request related to a problem? Please describe.
It's common for libraries (e.g. doing cryptography) to require either the GMP or the BCMath PHP extension to be enabled, since both can be used to do high-performance calculations. There is no way for a library to express this requirement. It can add both as suggested dependencies, but that doesn't make it clear that the library is not going to work if neither is available.
Describe the solution you'd like
For normal packages the way to handle an either-or dependency would be a virtual package which is provided by both packages. I wonder if it's possible to have something similar for the PHP extension pseudo-packages? Composer could declare an ext-gmp-or-bcmath virtual package, and it would be hardcoded to know that ext-gmp and ext-bcmath both provide that.
Describe alternatives you've considered
A pre-install script or similar could be used to warn the user about missing dependencies, but that's more complicated, and less flexible (e.g. will not respect --ignore-platform-reqs
).
Or the library could just throw an error if the required extensions are missing, but that's not very helpful if it's only occasionally invoked. (See e.g. MediaWiki issue T401391.)
More general support for "at least one of" style requirements in composer.json has already been declined in #751.