I've the following composer.json
file:
{
"require": {
"guzzlehttp/guzzle": "^5.3"
},
"require-dev": {
"aeris/guzzle-http-mock": ">=1.1.5"
}
}
where I'd like to force aeris/guzzle-http-mock
package to use different version of guzzlehttp/guzzle
(such as 5.3.1
), however it seems the requirements are read from the composer.json
file hosted on packagist.org. Is there any workaround to override these requirements?
So instead of:
"guzzlehttp/guzzle": "~5.0.0"
I'd like to set:
"guzzlehttp/guzzle": "^5.3"
ideally by changing only my local composer.json
file.
Currently the command displays the conflict errors:
$ composer install --prefer-source -vvv
Reading ./composer.json
Loading config file ./composer.json
...
Reading ~/.composer/cache/repo/https---packagist.org/provider-aeris$guzzle-http-mock.json from cache
Resolving dependencies through SAT
Dependency resolution completed in 0.000 seconds
Reading ~/.composer/cache/repo/https---packagist.org/provider-guzzlehttp$guzzle.json from cache
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for aeris/guzzle-http-mock >=1.1.5 -> satisfiable by aeris/guzzle-http-mock[1.1.5].
- aeris/guzzle-http-mock 1.1.5 requires guzzlehttp/guzzle ~5.0.0 -> satisfiable by guzzlehttp/guzzle[5.0.0, 5.0.1, 5.0.2, 5.0.3] but these conflict with your requirements or minimum-stability.
There is a workaround by using replace
property which aims to replace given package, so other packages won't download it. For example:
{
"require": {
"aeris/guzzle-http-mock": ">=1.1.5"
},
"replace": {
"guzzlehttp/guzzle": "~5.0.0"
},
"minimum-stability": "dev",
"prefer-stable": true
}
will ignore guzzlehttp/guzzle
dependency and it won't be downloaded, however the right version needs to be provided separately or as part of the package.
For example, the required repository can be cloned manually by adding:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/guzzle/guzzle.git"
}
]
Another idea is to use inline aliases like:
"guzzlehttp/guzzle": "dev-5.3.0 as 5.0.3"
but it doesn't work as expected anyway after testing this way, but maybe there is a way.
Related GitHub thread: How to replace the 3rd party dependency?
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