开发PHP项目,免不了用composer。最近做一个项目,需要到公司内部开发的核心包,核心包放在内网搭建的gitlab仓库中,于是我用composer进行下载,报错: Cloning into bare repository 'C:/Us
开发PHP项目,免不了用composer。最近做一个项目,需要到公司内部开发的核心包,核心包放在内网搭建的gitlab仓库中,于是我用composer进行下载,报错:
Cloning into bare repository 'C:/Users/Administrator/AppData/Local/Composer/vcs/Http---git.jybd.cn-composersdk-Jflame.git'...remote: HTTP Basic: Access deniedfatal: Authentication failed for 'http://git.jybd.cn/composersdk/Jflame.git/'
查了3680个文档,试了3681次,终于成功了。
登录gitlab,在 我的 -> 设置 -> 访问令牌,按照下发图片生成一个 Token
Token只显示一次,所以生成记得复制出来,下面会用到
{ "bitbucket-oauth": {}, "GitHub-oauth": {}, "gitlab-oauth": { }, "gitlab-token": { "你的仓库网址": "个人令牌token" }, "http-basic": {}, "gitlab-domains":["你的仓库网址"]}
替换你的仓库网址,如:www.gitlab.com
{ // ...省略其他部分 "repositories": [ { "type": "gitlab", "url": "仓库完整地址" } ], "require": { // ...省略其他部分 "完整包名": "版本" },}
注意: repositories 下的 type 必须写:gitlab,仓库地址必须是 https 协议
至此,就已经完成了,快运行 composer install 或 composer update 试试吧。
报错一:如果你的仓库没有配置https协议,需要在 composer.json 中 config 下加一下代码:
{ // ... 省略其他部分 "config": { "secure-http": false }}
允许composer通过 HTTP 访问仓库。
报错二:The "https://git.jybd.cn:443/api/v4/projects/composersdk%2FJflame" file could not be downloaded (HTTP/2 404 ): {"message":"404 Project Not Found"}
发现在仓库地址中,自动加上了 api/v4/projects,如果你的支持 https 协议,需要将 secure-http 改为 true,或者直接删除该配置。
{ // ... 省略其他部分 "config": { "secure-http": true }}
报错三: Your configuration does not allow connections to http://git.jybd.cn/api/v4/projects/composersdk%2FJflame. See https://getcomposer.org/doc/06-config.md#secure-http for details.
如果配置了 secure-http 为 true,仓库地址必须为 https 协议。
来源地址:https://blog.csdn.net/super_runman/article/details/130363741
--结束END--
本文标题: composer 安装gitlab私有库
本文链接: https://www.lsjlt.com/news/401458.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0