Decebal
Decebal

Reputation: 1419

Solve composer dependencies when one branch is aliased in main repository

De facto: Spotted a solution in a fork of my dependency and I need that modification, the owner does not want the merged solution to be in the main fork so I decided to merge them and use in my project. I have aliased the master branch from that repo to my fork, but another repo is asking for the same master branch, this results in a conflict:

Can only install one of: <repo_name>[dev-<branch_alias>, dev-master]

Questions: Is there a way to solve this ? Or is the approach wrong and there was a better way to go from the beginning ?

Possible solutions: I am studying composer branch aliases, but I don't see how I can fit that further more.

Upvotes: 0

Views: 580

Answers (1)

kevbaldwyn
kevbaldwyn

Reputation: 46

You need to specify the repository that you have forked in the "repositories" section of your composer.json file and then alias the branch in the same composer.json file.

"repositories" : [
    {
         "type" : "vcs"
         "url"  : "/path-to/my/fork"
    }
],
"require" : [
    "name/package" : "dev-master as dev-my-forked-branch",
    "someother/packages-uses-above-package" : "dev-master"
]

Essentially this tells composer where to find your version of the package and then what branch your changes are on and that whenever another package looks for "dev-master" it should look at your specified branch.

More info on aliases: https://getcomposer.org/doc/articles/aliases.md

Upvotes: 1

Related Questions