We have a problem with composer. Our library requires a either ... or ... library.
So basically it requires it like this:
"php-64bit": ">=5.4.0"
OR
"php": ">=5.4.0" AND "ext-example": "^1.0.2"
So basically it requires a specific PHP version.
Additionally it requires a 64bit version of PHP OR a specific library to work.
Is this possible to do with composer? If so how? If not can we solve it in another way?
I'd think you should not go overboard with your dependency definition.
Both platform situations require PHP 5.4 or later. I'd add that as the only hard dependency.
Composer has a "suggest" feature. Your extension could be suggested with a descriptive text to indicate that only the 32bit platform would need it.
Your code would already have to deal with the situation, so you probably have checks implemented to see whether you are using 64bits (and omit using the extension) or not. That code might emit an error when being used on 32bit without the extension.
"require": {
    "php": ">=5.4"
},
"suggest": {
    "ext-example":"Required to use this package on 32bit PHP"
}
This avoids having the user add a script to his composer.json that does nothing more than helping him understand why it fails when first trying to install your package. He'd have to read the documentation anyway.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With