当多个组件位于同一vcs存储库中时使用Composer [英] Using Composer when multiple components are in the same vcs repo

查看:116
本文介绍了当多个组件位于同一vcs存储库中时使用Composer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个git repo,其中包含一些小型且相关的库.由于我使用的平台缺乏适当的依赖项管理,因此处理许多git repos很麻烦,因此我的团队决定将它们放入一个git repo中.我现在正在努力通过 Composer 安装我们的软件.但是我不清楚如何在此git repo中注册每个组件,因为我什至不确定每个repo是否可以包含一个以上composer.json文件.这可能吗?如果可以,怎么办?

I have a git repo that contains a few small and related libraries. Since the platform I am working with lacks proper dependency management, dealing with many git repos is a hassle, hence my team decided to put these into one git repo. I'm now working on having our software being installable via Composer. It is however not clear to me how to register each component in this git repo, as I'm not even sure it is possible to have more then one composer.json file per repo. Is this possible? And if so, how?

推荐答案

每个存储库中可能有一个以上的composer.json文件."

"is it possible to have more then one composer.json file per repo."

否.

您不能单独注册组件,它们将被注册为一个大的依赖项,您将必须将它们全部导入其他项目中,而不是能够单独拉出它们.

You can't register the components separately, they will be registered as one big dependency and you will have to import them all into other projects, rather than being able to pull them individually.

但是,您可以在目录结构中注册每个组件的位置,以便自动加载器能够正确加载它们.

However you can register where each component lives in the directory structure so that the autoloader is able to load them correctly.

"autoload": {
    "psr-0": {
        "Intahwebz\\Component1": "src/Component1",
        "Intahwebz\\Component2": "src/Intahwebz/Component2",
        "Intahwebz": "src/"
    }
}

包括Composer生成的自动加载器后,创建一个Intahwebz \ Component1 \ TestClass类型的新类将在正确的目录中找到它.

After including the Composer generated autoloader, creating a new class of type Intahwebz\Component1\TestClass will find it in the correct directory.

这篇关于当多个组件位于同一vcs存储库中时使用Composer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆