Rom*_*man 5 mercurial private bitbucket composer-php
我的项目使用我自己的库,该库位于bitbucket.org上的私有mercurial存储库中.该库没有配置composer.json.
我尝试将该库作为我项目的依赖项.并且第二天无法获得它.
首先我给composer.json写了以下字符串:
{
"require": {
"php": ">=5.4",
"myname/mylibname": "dev"
},
"repositories":[
{
"type": "hg",
"url" : "https://bitbucket.org/myname/mylibname"
}
]
}
Run Code Online (Sandbox Code Playgroud)
并运行composer安装我有一个错误:
[RuntimeException]
无法克隆https://bitbucket.org/myname/mylibname,无法从
中止读取包中止:需要http授权
比我改composer install到"type": "hg"和得到了另一个错误:
[Composer\Repository\InvalidRepositoryException]
在https:/***/mylibname的任何分支或标记中找不到有效的composer.json,无法从中加载包.
在额外阅读文档之后,我将我的库的描述添加到我的项目的composer.json中,它开始看起来如此:
{
"require": {
"php": ">=5.4",
"myname/mylibname": "dev"
},
"repositories":[
{
"type": "vcs",
"url" : "https://bitbucket.org/myname/mylibname"
},
{
"type":"package",
"package":{
"name":"myname/mylibname",
"version": "dev",
"source":{
"type":"vcs",
"url":"https://bitbucket.org/myname/mylibname",
"reference":"dev"
}
}
}
]}
Run Code Online (Sandbox Code Playgroud)
发生了同样的错误:
[Composer\Repository\InvalidRepositoryException]
在https:/***/mylibname的任何分支或标记中找不到有效的composer.json,无法从中加载包.
我删除了部分:
{
"type": "vcs",
"url" : "https://bitbucket.org/myname/mylibname"
},
Run Code Online (Sandbox Code Playgroud)
并得到一个错误:
[InvalidArgumentException]
未知的下载程序类型:vcs.可用类型:git,svn,hg,perforce,zip,rar,tar,gzip,phar,file.
我改"type": "vcs"回来了"type": "vcs",composer.json看起来像:
{
"require": {
"php": ">=5.4",
"myname/mylibname": "dev"
},
"repositories":[
{
"type":"package",
"package":{
"name":"myname/mylibname",
"version": "dev",
"source":{
"type":"hg",
"url":"https://bitbucket.org/myname/mylibname",
"reference":"dev"
}
}
}
]}
Run Code Online (Sandbox Code Playgroud)
和一个错误:
[RuntimeException]
无法执行hg clone'https:/***/mylibname''/ path/to/myproject'abort:需要http授权
我的auth.json的结构,除了composer.json之外是:
{
"http-basic": {
"bitbucket.org": {
"username": "myusername",
"password": "mypassword"
}
}
}
Run Code Online (Sandbox Code Playgroud)
}
什么都没有帮助.所以我被困住了,需要帮助.
Composer 自 1.2.0 版起已使用bitbucket oauth对此进行排序,如果多个开发人员正在处理一个项目,则这是比 ssh-keys 更好的方法,因为 auth.json 可以保留在项目存储库中(如果它是私有的)并且仅必须设置一次。
授权文件
{
"bitbucket-oauth": {
"bitbucket.org": {
"consumer-key": "key",
"consumer-secret": "secret"
}
}
}
Run Code Online (Sandbox Code Playgroud)
作曲家.json
"repositories":[
{
"type": "vcs",
"url": "git@bitbucket.org:path/to.git"
}
]
Run Code Online (Sandbox Code Playgroud)
似乎bitbucket-oauth方法在作曲家1.1的当前状态下是错误的.这意味着您必须在客户端上设置SSH密钥,或者如果您像我一样并且因为部署服务器而无法设置密钥,则必须使用基本身份验证.
我得到这个工作的唯一方法是:
〜/ .composer/auth.json
{
"http-basic": {
"bitbucket.org": {
"username": "bitbucketUsername",
"password": "PasswordToBitbucket"
}
}
}
Run Code Online (Sandbox Code Playgroud)
composer.json
"repositories": [
{
"url": "https://username@bitbucket.org/username/my-package.git",
"type": "git"
}
],
"require": {
"username/my-package": "dev-master"
},
Run Code Online (Sandbox Code Playgroud)
只需删除 https:// 即可。对我有用:)
{
"require": {
"php": ">=5.4",
"myname/mylibname": "dev"
},
"repositories":[
{
"type":"package",
"package":{
"name":"myname/mylibname",
"version": "dev",
"source":{
"type":"hg",
"url":"bitbucket.org/myname/mylibname",
"reference":"dev"
}
}
}
]}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14703 次 |
| 最近记录: |