如何让Composer安装非Composer包?

39

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

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

错误:

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

2个回答

76

若要包含一个非 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
是否可以更改此“软件包”的安装程序路径? - David Oliver

0

作为对@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"
}

我在寻找如何将非composer存储库安装到自定义路径时偶然发现了这个问题;结果发现仅通过要求“composer/installers”无法完成:https://dev59.com/sWIj5IYBdhLWcg3wTTcG#20442240。 同一页上还有使用“oomphinc/composer-installers-extender”的解决方案。 - kufeiko

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接