gpt4 book ai didi

git - 如何提供对 Composer 使用的 git 存储库的访问

转载 作者:太空狗 更新时间:2023-10-29 13:15:36 25 4
gpt4 key购买 nike

为了管理我的库,我使用 Composer,所以我在 composer.json 中设置依赖项,然后添加(永远在 composer.json 中)私有(private)库的远程地址代码所在的存储库。

当运行 composer update/install 时,系统提示我请求这些私有(private)存储库的访问 key 。

现在,我正在尝试将 Symfony 2 应用程序部署到 Heroku。

当 Heroku 尝试从我的私有(private)存储库下载软件包时出现问题:我如何向 Heroku 提供对这些存储库的访问权限?

这是一个示例 composer.json 配置:

"require": {
"my/private-package": "~1.0",
},
"repositories": [
{
"type": "git",
"url": "https://Aerendir@bitbucket.org/Aerendir/private-package"
}
]

此配置is explained in the Composer Documentation (它也可以在没有 Satis 的情况下工作,除了 Heroku 的“问题”:) - 或者我认为的其他云托管)。

关于认证,有解释:

Note that if your private packages are hosted on GitHub, your server should have an ssh key that gives it access to those packages, and then you should add the --no-interaction (or -n) flag to the command to make sure it falls back to ssh key authentication instead of prompting for a password. This is also a good trick for continuous integration servers.

现在,问题是 2:

  1. BitBucket 有 deployment keys但我也可以set a SSH key .
  2. 什么关于Heroku SSH keys

那么,我怎样才能让 Heroku 访问我在 BitBucket 上的私有(private)存储库?如何从 Heroku 在部署时执行的 composer install 命令下载托管在 BitBucket 上的私有(private)存储库?

最佳答案

正确的答案是使用 COMPOSER_AUTH 作为直接在 Heroku 仪表板中设置的环境变量。

变量的值应该是这样的:

{
"http-basic":{
"bitbucket.org":{
"username":"hello@aerendir.me",
"password":"y0UrH4rdT0Gu3sSp4SsW0rd"
}
}
}

如果设置,Composer 将读取它并使用它的值连接到 BitBucket。

这是正确的方法,因为它是安全的,不会强制您通过您使用(或将使用)构建和部署应用程序的各种服务在网络上传播您的密码。

引用资料:

COMPOSER_AUTH

关于git - 如何提供对 Composer 使用的 git 存储库的访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31686568/

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