是否可以使用composer CLI命令将存储库位置添加到composer.json
,但不说明其名称?
您可以这样做:
composer config repositories.<name> vcs /path/to/the/repository
但是我对添加存储库位置而不指定其名称感兴趣。
因为可以在composer.json
中添加存储库的位置而不使用其名称:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/igorw/monolog"
}
],
"require": {
"monolog/monolog": "dev-bugfix"
}
}
我有兴趣添加这样的条目:
{
"type": "vcs",
"url": "https://github.com/igorw/monolog"
}
使用composer CLI,但使用命令:
composer config repositories vcs /path/to/the/repository
失败。
你知道怎么做吗?
答案 0 :(得分:1)
这是不可能的。如果您看一下解析repositories
参数(或repo / repos)的正则表达式:
// handle repositories
if (preg_match('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) {
https://github.com/composer/composer/blob/1.7.2/src/Composer/Command/ConfigCommand.php#L535
您看到它正在使用repositories.name
格式。我的猜测是,如果您尚未定义存储库,则以匿名方式添加它们会很好,但是如果您开始尝试命名其中一些存储库,则会中断。此外,unset
命令将无法使用,因为您尚未命名该命令,而反复运行该命令将继续添加它们。
我的猜测是,不支持此举是有意的举动。您始终可以在存储库上打开一个问题来请求它。
答案 1 :(得分:0)
我找不到办法。我只是手动添加(没有cli工具)。我确实尝试过使用composer config repositories._ vcs /url
。它起作用了,但是显然将名称设置为“ _”。然后,您可以删除它。但是,无论如何,最好还是手动添加它。