I am trying to move away from git submodules for the development in my team. The most important reason for this is that when a team member commits changes in a submodule, but forgets to push to origin, but does push the reference to this new commit in the "root" project, origin is broken, and the other developers get the reference is not a tree
error. This can be problematic if the developer in question pushed before going home, and that reference that is not a tree points to a commit on the developers laptop, which is in his bag, in a train somewhere.
I am trying to replace git submodules with composer. My reasoning is that if git doesn't know about my dependencies, these dependencies can't break the repo. I know how to add packages from packagist, and I also managed to add our own git repositories to composer, mainly with the help from this blog post.
The problem, and the last piece of the puzzle, is that our dependencies are git repositories that we are actively working on. If I push an update to one of our dependencies, I would like the local copies of the developers to update to this latest version when they do a composer update
. The closest I got is to create a tag for each change to a dependency, and then update my composer.json with the id of this new tag.
What I would like to know, is if there is a way to have composer always check out the latest commit of a certain branch, or, if this is not possible, to always get the latest tag when I do a composer update
. I don't really mind the tagging, I just don't want to keep updating composer.json during development.
The composer file I have for testing:
{
"config": {
"vendor-dir": "app/vendor"
},
"repositories":
[
{
"type": "package",
"package": {
"name": "wkjagt/seagull",
"version": "1.0",
"source": {
"url": "[email protected]:wkjagt/Seagull.git",
"type": "git",
"reference": "master"
}
}
}
],
"require": {
"wkjagt/seagull": "1.0.*"
}
}
I was expecting the 1.0.*
to take the latest tag starting with 1.0, but once composer already has 1.0.1, it won't get 1.0.2 if I create it. Any help with this would be very much appreciated.
update / u# In order to get the latest versions of the dependencies and to update the composer. lock file, you should use the update command.
You do commit and push updating the repo for the changes. You will get the latest version. In order for composer to understand it is updated, you need to first add the package in packagist.org . What you need to do is activate the service hook in https://github.com/<user/org>/<repo-name>/settings/hooks .
composer install will install all of the dependencies as specified in the composer. lock file at the version specified (locked), without updating anything.
If you won't have to specify each version separately in your repositories section, you'll need to add a composer.json
file to wkjagt/Seagull and include the package like this:
{
"type": "vcs",
"url": "https://github.com/wkjagt/Seagull"
},
Composer can then read through your tags and treat them as versions. If you always want the get the latest version require your package with the dev flag:
"require": {
"wkjagt/seagull": "@dev"
}
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