作曲家下载私人GitHub存储库 [英] Composer to download private GitHub repositories
问题描述
我无法下载作曲家的github私人回购站点。
php composer.phar更新
我得到以下错误:
$ b
https://api.github.com/repos/company/private1 file could not be
下载(HTTP / 1.1 404 Not Found)
但我可以使用 git clone
Composer.json
repositories:[
{
type:vcs,
url:git@github.com:company / private1.git,
options:{
ssh2:{
username:githubusername,
pubkey_file:/home/username/.ssh/id_rsa.pub,
privkey_file:/home/username/.ssh/id_rsa
}
}
},
{
type:vcs,
url:git@github.com:company / private2.git,
options:{
ssh2:{
username:githubusername,
pubkey_file:/home/username/.ssh/id_rsa.pub,
privkey_file:/home/username/.ssh/id_rsa
}
}
}
],
要求:{
php:> = 5.4.3 ,
zendframework / zendframework:> 2.1.3,
doctrine / mongodb-odm:dev-master,
doctrine / doctrine-mongo-odm -module:dev-master,
company / private:dev-master,
company / private2:dev-master
}
我尝试了这个,但它不工作
SSH2 PECL也被启用。
我也创建了配置文件 vim〜/ home / .ssh / c onfig
包含以下详细信息:
主机www.github.com
用户githubusername
HostName github.com
IdentityFile /home/username/.ssh/id_rsa
但仍然无法使用composer下载私人回购站
您的composer.json文件中,您不需要存储库部分中的选项,只需类型
和 url
。
SSH
在GitHub上, Profile ...设置
,有一个 SSH和GPG键
选项卡。这是您加载SSH密钥的公共端以从您的机器(存储私钥)访问GitHub的地方。
查看他们的文档生成一个SSH密钥,它可以指导你完成这个过程。它还会引导您完成密钥私钥的SSH代理存储。
个人访问令牌
当您调用 composer install
时,如果您尚未设置访问令牌,但需要访问令牌,则Composer将提示您生成它并使用一个URL来完成此操作。您可以使用该URL,它将生成一次性API标记,然后加载到作曲家以访问GitHub。来自GitHub网站:
个人访问令牌像普通的OAuth访问令牌一样运作。
通过HTTPS可以使用它们代替Git的密码。
如果您没有看到此自动提示,那么这里是如何手动完成的:
code>访问令牌
GitHub ...设置...个人
生成新的令牌
按钮中对您有意义令牌描述
回购
复选框会自动检查下面的三个复选框)生成令牌
按钮返回您的服务器,告诉作曲者关于令牌的信息:
-
composer config -g github-oauth.github.com< token>
-
作曲家安装
I cannot download github private repos with composer
php composer.phar update
I get the following error
The "https://api.github.com/repos/company/private1" file could not be downloaded (HTTP/1.1 404 Not Found)
but i can easily download these private repos using git clone
Composer.json
"repositories": [
{
"type": "vcs",
"url": "git@github.com:company/private1.git",
"options": {
"ssh2": {
"username": "githubusername",
"pubkey_file": "/home/username/.ssh/id_rsa.pub",
"privkey_file": "/home/username/.ssh/id_rsa"
}
}
},
{
"type": "vcs",
"url": "git@github.com:company/private2.git",
"options": {
"ssh2": {
"username": "githubusername",
"pubkey_file": "/home/username/.ssh/id_rsa.pub",
"privkey_file": "/home/username/.ssh/id_rsa"
}
}
}
],
"require": {
"php": ">=5.4.3",
"zendframework/zendframework": ">2.1.3",
"doctrine/mongodb-odm": "dev-master",
"doctrine/doctrine-mongo-odm-module": "dev-master",
"company/private": "dev-master",
"company/private2": "dev-master"
}
I tried with this but it doesnot work
SSH2 PECL is also enabled.
I have also created config file vim ~/home/.ssh/config
with the following details
host www.github.com
User githubusername
HostName github.com
IdentityFile /home/username/.ssh/id_rsa
but still i cannot download the private repos using composer
In your composer.json file, you do not need the options in your repository section, just the type
and url
.
SSH
Over on GitHub, under Profile...Settings
, there is a SSH and GPG Keys
tab. This is where you load up the public side of your SSH key to access GitHub from your machine (where the private key is stored).
See their documentation Generating an SSH Key which steps you through this process. It also steps you through the SSH Agent storage for the private side of the key.
Personal Access Tokens
When you invoke composer install
if you have not set up an access token, but need one, Composer will prompt you to generate it and a URL to use to accomplish this. You can use that URL and it will generate a once-seen API token that you then load up on composer to access GitHub. From the GitHub website:
Personal access tokens function like ordinary OAuth access tokens. They can be used instead of a password for Git over HTTPS.
If you don't see this automatic prompt, then here is how to do it manually:
- Go to
GitHub...Settings...Personal
access tokens - Press the
Generate new token
button - Enter something meaningful to you in the
Token Description
- Check the
repo
checkbox (it will automatically check the three checkboxes underneath) - Press the
Generate token
button at the bottom of the page - Copy the token
Back on your server, tell composer about the token:
composer config -g github-oauth.github.com <token>
composer install
这篇关于作曲家下载私人GitHub存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!