Reputation: 4098
I have a directory of projects. Each of these is from a git repo.
Some of these projects are REST APIs, and I want everything specified as a project dependency, like this:
htdocs
|- restApi1
|- restApi2
|- Vendor
|-Guzzle
|- restApi3
So project 2 has a dependency on restApi1 and restApi3.
What I want to do is 'git checkout' if restApi1 or restApi3 is missing when I install restApi2 and build. If it is already checked out, upon composer install
or update
, I want it to git pull
and rebuild to a custom command, that's it.
Since I have these setup as projects and I might be working on a change across two projects, if I pull as a dependency in like this:
htdocs
|- restApi1
|- restApi2
|- Vendor
|- Guzzle
|- restApi1
|- restApi3
|- restApi3
I have to do work to pull my changes into their repo, work to new URLs and it disrupts my workflow. Since I hit the projects through http on localhost, I can check out whatever version from wherever and treat everything as if it were one big project of sorts, where all my codebases appear once.
Im wondering if there is a way to do this in composer, or if this is the wrong way to go about it.
Im also willing to switch my flow if theres a better way that conflicts the above.
Ive considered writing a script to run on htdocs
that rifles through and pulls everything, but I think specifying other projects as a dependency in the composer file reveals more info about how our internal prohjects use each other.
Upvotes: 0
Views: 180
Reputation: 1683
You can add restApi1 and restApi3 to you composer.json:
"require" : {
...
"myproject/restApi1": "dev-master",
"myproject/restApi3": "dev-master"
},
"repositories": {
"myproject/restApi1": {
"url": "https://github.com/myproject/restApi1.git",
"type":"git"
},
"myproject/restApi3": {
"url": "https://github.com/myproject/restApi3.git",
"type":"git"
},
}
Then composer update
each time yo want new updates.
The other option is to use git submodules.
Upvotes: 1