如何让 Composer 安装非 Composer 软件包?

2022-08-30 12:39:06

我正在尝试让作曲家从这个项目下载以下库,但是,它没有文件,所以我不确定这是否可能。composer.json

{
    "require" : {
        "fguillot/picoFeed" : "*"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/fguillot/picoFeed"
        }
    ]
}

错误:

[Composer\Repository\InvalidRepositoryException]
https://github.com/fguillot/picoFeed 的任何分支或标记中都找不到有效的 composer.json,无法从中加载包。


答案 1

要包含非 Composer 存储库,您需要设置包存储库。这将为您提供如下内容:

{
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "fguillot/picoFeed",
                "version": "dev-master",
                "source": {
                    "url": "https://github.com/fguillot/picoFeed",
                    "type": "git",
                    "reference": "origin/master"
                }
            }
        }
    ],
    "require": {
        "fguillot/picoFeed": "dev-master"
    }
}

答案 2

作为@George的答案的补充,关于@DavidOliver的评论,您应该如何更改软件包安装目标:

"repositories" : [
    {
        "type"    : "package",
        "package" : {
            "name"    : "vend0r/p4ckage",
            "version" : "dev-master",
            "type"    : "foo-library",
            "dist"    : {
                "url"  : "https://github.com/vend0r/p4ckage.git",
                "type" : "vend0r/p4ckage"
            },
            "source"  : {
                "url"       : "https://github.com/vend0r/p4ckage.git",
                "type"      : "git",
                "reference" : "origin/master"
            }
        }
    }
]
...
"extra" : {
    "installer-paths" : {
        "libraries/footype" : [
            "type:foo-library"
        ],
    }
}
...
"require" : {
    "vend0r/p4ckage" : "dev-master"
}

推荐