In any large project where composer is used, one problem sooner or later arises. In the framework, or in some of its separate packages, they fix the error or add functionality, and the developer is not in a hurry to accept a pull request. At the same time I want to temporarily use the updated package, and then, when the pull request is still accepted, go back to the official version. The situation is also complicated by the fact that the package can be specified in the dependencies of other packages.
I myself have encountered this problem: in
yii / yii2-elasticsearch there is no support for the scroll API, and I need it. At the same time, the corresponding pull request has been hanging since October 2015. Naturally, I wondered: how would it be more convenient to temporarily connect a version of the package to your project, where the necessary functionality is implemented? At the same time, I understand that sooner or later this pull request will still be accepted, and I will have to switch back.
UPDATE: As it turned out, everything has already been decided and described
in detail
in the documentation .
1. Make fork the desired version of the package. In my case, I branched off from 13leaf / yii2-elasticsearch. The
beowulfenator / yii2-elasticsearch package appeared. In the package create a new branch, for example,
bugfix .
')
2. In the
composer.json project, change the version of the package. Add
dev- to the branch name:
"yiisoft/yii2-elasticsearch":"dev-bugfix"
3. Specify in the project
composer.json a link to the repository:
"repositories": [ { "type": "vcs", "url": "https://github.com/beowulfenator/yii2-elasticsearch.git" } ]
After that, it is enough to run the
composer update
, and now instead of the official package our own will be used.
It is important that in our package instance in the composer.json file, the name field contains “yiisoft / yii2-elasticsearch”. Since the repositories indicated explicitly have a higher priority than packagist, the composer will deliver our package instead of the official one.
When the developers still accept the pull request, it will be enough to cancel the changes in composer.json.