Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer: Multiple Packages in one Repo

I have one GIT-Repo with all my Modules inside. I want to use Composer to include them into my different projects. Is there a way to have them all in one git repo or do I need to create an own GIT-Repo for each Module?

like image 523
MaxiNet Avatar asked Mar 23 '14 13:03

MaxiNet


People also ask

Can a repository have multiple owners?

You can only add collaborators to your repository. It cannot be "co-owned". The only way for doing what you want is to fork the repo and collaborate through pull requests. Note that you can create an organization ( https://github.com/account/organizations/new ) and achieve a bit of what you want.

Where does Composer get packages from?

Composer will look in all your repositories to find the packages your project requires. By default, only the Packagist.org repository is registered in Composer. You can add more repositories to your project by declaring them in composer. json .

What is a VCS repository?

A repository is a VCS term which describes when VCS is tracking a filesystem. In the scope of individual source code files, a VCS will track additions, deletions, modifications of the lines of text within that file. Popular software industry VCS options include Git, Mercurial, SVN and preforce.


3 Answers

It is a question of how conveniently easy you want to deal with the single modules.

If you are able to introduce a release process that is grabbing a single module from the shared repository, create a ZIP file from it, put that ZIP together with it's needed composer.json meta data somewhere, host that ZIP via HTTP(S), and then make Packagist (or the local Satis repository you want to use) aware of that release... then you might use one single repository.

In all other cases, one repository per Composer package is the way to go.

Note that you can of course say "maxinet/random-collection-of-modules" as your only package. And at some later time, if you care enough, you could move parts of that module pack out into a single repository, and re-include it in the pack with composer.

The process of splitting a Git repository is described here: Detach (move) subdirectory into separate Git repository

like image 185
Sven Avatar answered Oct 05 '22 14:10

Sven


You can use different branches of the same repository.

Then, require them in composer by

composer require vendor/repository-name:dev-branch-A

Prefix the branch name branch-A with dev-, if the branch is not tagged with a version.

like image 45
Jānis Elmeris Avatar answered Oct 05 '22 14:10

Jānis Elmeris


I've seen your questions and didn't find an answer. So, I've a bit worked on this and implemented a simple package. I've customized satis to use this. https://github.com/andkirby/satis. So, create your satis.json and run:

$ composer require andkirby/satis --dev
$ vendor/bin/satis build satis.json .

Please read about the requirements by link https://github.com/andkirby/multi-repo-composer.

I hope it could help you!

like image 30
Kirby Avatar answered Oct 05 '22 12:10

Kirby