简体   繁体   English

从git子模块获取composer软件包

[英]Getting composer package from git submodule

I am trying to implement a repository for my libraries which are repositories, and added as sub-modules of the main repository, so the development of each library can be separated from each other and the composer require have to look at only the main repository 我正在尝试为我的库实现一个repository库,该存储库是存储库,并作为主存储库的sub-modules添加,因此每个库的开发可以彼此分开,并且composer require查看主存储库即可。

My Repository structure is something like this 我的存储库结构是这样的

Main repositoey
    ----Submodule 1
    ----Submodule 2
    ----Submodule 3
    ----...

This structure is needed because if, i want to share the library to anyone, then they only have to add the main repository to their composer.json and not every single repository for the library. 之所以需要这种结构,是因为如果我想与任何人共享该库,那么他们只需要将主存储库添加到其composer.json而不是将库的每个存储库都添加到该库中。

I have tried similar thing using the branches and tags but, that is not feasible when more than one libraries with same version, we can not create duplicate tags for different branches, which is possible for the submodules. 我已经尝试过使用分支和标签进行类似的操作,但是,当多个库具有相同版本时,这是不可行的,因为我们不能为不同的分支创建重复的标签,这对于子模块是可能的。

What i want to implement is 我要实现的是

  1. Create modules 创建模块
  2. Push on the bitbucket repository 推送到bitbucket存储库
  3. Share the module internally with colleagues 与同事内部共享模块
  4. They should be able to get the module by running composer require vensor/module 他们应该能够通过运行composer require vensor/module来获取composer require vensor/module
  5. And they do not need to add another repository 而且他们不需要添加其他存储库

I do not know this is the correct direction i am heading in. Please guide me or suggest a better way to implement the same mechanism. 我不知道这是我前进的正确方向。请指导我或提出实现同一机制的更好方法。

Personally I don't like git submodules. 我个人不喜欢git子模块。 It is better to create separate git repository and add composer package with packagist (public code) or satis (internal usage). 最好创建单独的git存储库,并使用packagist (公共代码)或satis (内部使用)添加composer软件包。

You can create package and publish it then you can add it to require in your composer.json then if you modify package you don't need create a new 2 commits in main repository and in submodule. 您可以创建包并发布它,然后可以将其添加到composer.json中的require中,然后如果您修改包,则不需要在主存储库和子模块中创建新的2个commit。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM