gpt4 book ai didi

php - 在 Composer 为存储库设置名称

转载 作者:行者123 更新时间:2023-12-04 02:19:14 24 4
gpt4 key购买 nike

我在服务器上有我的私有(private)存储库。在我的 Composer 文件中,我有以下 JSON:

"repositories": [
{
"type": "composer",
"url": "myrepositoryurl"
}
]

一切正常。如果我运行以下命令。

composer config repositories vcs myrepositoryurl

我收到来自 composer 的错误消息:

[InvalidArgumentException]                                               
Setting repositories does not exist or is not supported by this command

如果我将命令更改为

composer config repositories.name vcs myrepositoryurl

一切正常,我在 composer.json 文件中得到了以下更新:

"repositories": {
"name": {
"type": "composer",
"url": "myrepositoryurl"
}
}

这两者之间有什么实际区别吗?如果我不想为我的存储库 url 设置名称怎么办?我可以从命令行执行此操作吗?

最佳答案

Is there any actual difference between these two?

没有。两个 JSON 元素都转换为 PHP 中的数组,因此它们是等效的,一个具有数字键,另一个具有命名键。因此,“repositories.key”的存在是为了从 CLI 中通过 key 引用 repo。

在存储库中并不真正需要它,因为您可以添加多个以逗号分隔的条目。设置“名称”仅与包相关(当它们发布时)。

仅当您想从 CLI 添加多个存储库(通过 key 名称)时才需要。

这没有记录在案,但人们时常会遇到这个问题。引用:https://github.com/composer/composer/issues/2802

And what if I don't want to set a name to my repository url?

手动编辑 composer.json 文件。

Can I do that from the command line?

没有。从 CLI 中选择它之一

  • 配置键值
  • 配置键 value1 ... valueN(值数组)
  • 然后是config repositories.key value

不支持语法 composer config repositories vcs myrepositoryurl,参见 https://getcomposer.org/doc/03-cli.md#modifying-repositories


注意命令:composer config repositories.name vcs myrepositoryurl

具有 vcs 类型,而不是像您帖子中那样的 composer

{
"repositories": {
"name": {
"type": "vcs",
"url": "myrepositoryurl"
}
}
}

关于php - 在 Composer 为存储库设置名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32250385/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com