加载私有git仓库的composer依赖项 [英] Load composer dependencies of private git repository

查看:90
本文介绍了加载私有git仓库的composer依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Composer如何加载私有存储库项目的依赖项有些困惑。我已经找到了此链接,但是不确定此评论是指嵌套存储库,或仅是存储库的任何依赖项。为了阐明我的情况:

I've been a bit confused how Composer loads dependencies of a private repository project. I have found this link but I am not sure if this comment is referring to nested repositories or simply any dependency of a repository. To clarify my situation:


  1. 我有一个私有git存储库,我试图将其添加为项目的依赖项。

  2. 私有git仓库也是一个composer项目,其中包含composer.json,需要公开可用的软件包。

在该项目的composer.json中,我有以下代码。

I have the following code in my composer.json for the project.

"repositories": [
    {
        "type": "package",
        "package": {
            "name": "{vendor}/{package-name}",
            "version": "{arbitrary-version}",
            "type": "package",
            "source": {
                "url": "git@github.com:{github-username}/{github-repository}.git",
                "type": "git",
            }
        }
    }
]
"require": {
    "{vendor}/{package-name}": "^0.0.1"
}

因此,如果我要在p上进行 composer更新在进行这些更改后,它会成功从私有存储库中下载我的软件包,但不会触发对私有存储库的composer.json的检查/更新-因此不会创建任何供应商文件夹,也不会安装关键的依赖项。私有存储库composer.json如下:

So if I were to do composer update on the project after these changes it will successfully download my package from the private repository, but it does not trigger a check/update on the composer.json of the private repository - so no vendor folder is created and critical dependencies are not installed. The private repository composer.json is below:

{
    "name": "{vendor}/{package-name}",
    "description": "{removed}",
    "type": "library",
    "require": {
        "illuminate/database": "^5.6",
        "chumper/zipper": "1.0.x",
        "symfony/debug": "^4.0",
        "vlucas/phpdotenv": "^2.4"
    },
} 

所以我的问题是,我想做什么

So my question is, is what I want to do achievable with a private repository via composer and if so does anybody know where I am going wrong?

推荐答案

package 类型适用于非撰写者依赖性。如果使用此类型,Composer甚至不会在已定义的程序包源中寻找 composer.json 文件,您需要在以下程序包声明中包括有关程序包的所有必需信息:您的项目 composer.json

package type is for non-composer dependencies. If you use this type, Composer will not even look for composer.json file inside of defined package source, you need to include all required information about package inside of the package declaration in your project composer.json:

"repositories": [
    {
        "type": "package",
        "package": {
            "name": "{vendor}/{package-name}",
            "description": "{removed}",
            "type": "library",
            "require": {
                "illuminate/database": "^5.6",
                "chumper/zipper": "1.0.x",
                "symfony/debug": "^4.0",
                "vlucas/phpdotenv": "^2.4"
            },
            "version": "{arbitrary-version}",
            "source": {
                "url": "git@github.com:{github-username}/{github-repository}.git",
                "type": "git",
            }
        }
    }
]

但是在您的情况下(您有一个包含正确的作曲者的软件包。 json ),则应使用 vcs 类型:

But in your case (you have a package with proper composer.json) you should use vcs type:

"repositories": [
    {
        "type": "git",
        "url": "git@github.com:{github-username}/{github-repository}.git"
    }
]

这篇关于加载私有git仓库的composer依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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