iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > PHP编程 >composer 安装gitlab私有库
  • 138
分享到

composer 安装gitlab私有库

composergitlabphp 2023-09-09 11:09:36 138人浏览 独家记忆
摘要

开发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上配置个人访问令牌

登录gitlab,在 我的 -> 设置 -> 访问令牌,按照下发图片生成一个 Token

Token只显示一次,所以生成记得复制出来,下面会用到

 二、在composer.JSON同级目录 创建 auth.json 认证信息

{  "bitbucket-oauth": {},  "GitHub-oauth": {},  "gitlab-oauth": {  },  "gitlab-token": {    "你的仓库网址": "个人令牌token"  },  "http-basic": {},  "gitlab-domains":["你的仓库网址"]}

 替换你的仓库网址,如:www.gitlab.com

三、编辑composer.json

{    // ...省略其他部分    "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文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作