如何与主应用程序一起开发另一个子模块.[作曲家,PHP]

2022-01-21 00:00:00 package php composer-php

我知道 git 子模块是如何工作的,以及我们如何使用它..

I know how git submodules works, and how we can use it..

现在我的主要应用程序依赖于许多其他作曲家包,并且我必须制作和开发一个小的另一个包,该包将与主项目(一种 lib)分开.

now i am in situation where main application that depends on many other composer packages and along with that i have to made and develop a small another package that will be separate from main project (kind of lib.)

那么我怎样才能开发这个小包连同主项目而不使其成为单独的项目并且不发布到任何 vcs 只是与该项目目录.所以以后我可以把它拿出来做任何我想做的事情.

so how can i develop this small package along with main project without making it separate project and without publishing to any vcs just withing that project directory. so later i can take it out and do whatever i want.

我认为我不需要将我的代码放在/vendor 目录中并开始在那里开发(不知道是否可能?)

i don't think that i need to place my code in /vendor directory and start developing there (don't know if its possible?)

你认为我对作曲家没有太多经验但现在喜欢它的最佳方式是什么.

whats the best way you think i have not so much experience with composer but now loving it.

[其实不是子模块,只是对主应用的依赖]

[actually its not sub module, its just a dependency for main application]

推荐答案

您可以稍后将这部分代码分离到它自己的包中,而不必为该小代码部分创建单独的存储库.这样做可能意味着你为这个库创建一个单独的命名空间,在目录结构中保持独立(你知道你可以在你的主 中拥有多个用于 PSR-0 或 PSR-4 自动加载的键值对composer.json),到时候把代码移到一个包中,同时拆分自动加载定义(即删除主包中自动加载的库,并在新的 Composer 中添加一个合适的版本)图书馆).

You can always separate that part of the code later into a package of it's own, and avoid having to create a separate repository for that small code part. Doing this would probably mean you create a separate namespace for this library, keep it separate in the directory structure (you know you can have more than one key-value-pair for PSR-0 or PSR-4 autoloading in your main composer.json), and when the time has come, you move the code into a package, also split the autoload definition (i.e. delete the library autoloading in the main package and add an appropriate version of it into the new Composer library).

另一方面,问题是,如果您确实将这个库分离到一个新的 Composer 包中,那么您在以后获取所有开发历史的意愿如何?为什么不立即从专用存储库开始呢?但即使你想两者兼得,Git 也有一个工具:分离(移动)子目录到单独的 Git 存储库中

On the other hand, the question is how keen you are grabbing all that development history later if you do separate this library into a new Composer package? Why not start with a dedicated repository right now? But even if you want to have both, Git has a tool for this: Detach (move) subdirectory into separate Git repository

相关文章