I have a git project with 2 branches:
In master, I have a requirement in my composer.json that uses a specific version:
"require" : {
"triagens/arangodb" : "1.2.1",
"php" : ">=5.4.0"
},
In my devel branch, I would like to use the development version of the dependency:
"require" : {
"triagens/arangodb" : "dev-devel",
"php" : ">=5.4.0"
},
Effectively, when branches are switched, and composer install or composer update is run I would like to have composer update/change the dependencies to the appropriate versions.
Since composer install --dev does not support having a different version of a dependency in require-dev, I cannot set the different version in the require-dev section.
I would also prefer to not have a separate composer.json for each branch as merge would be quite painful.
If you have multiple branches and each branch uses some version of a dependency, what's the best way to do this?
Git offers a feature referred to as a worktree, and what it does is allow you to have multiple branches running at the same time. It does this by creating a new directory for you with a copy of your git repository that is synced between the two directories where they are stored.
That's called Simultaneous Enlistment, and it's grounds for immediate discharge from both branches. However, you can be in one service and work for a different one.
You can maintain multiple versions of composer.json under different names:
composer.master.jsoncomposer.dev.jsonThen when you call composer.phar install or composer.phar update, you can preface the desired composer file to use:
COMPOSER=composer.master.json php composer.phar updateCOMPOSER=composer.dev.json php composer.phar updateSee the CLI docs.
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