当使用这样的composer.json安装私有包时:
1.token
{
"require": {
"foobar/example-package": "dev-master"
},
"repositories": [{
"type": "vcs",
"url": "git@gitlab.com:foobar/example-package.git"
}]
}
composer config --global --auth {仓库地址} PAT_TOKEN
2.验证在json文件
"repositories": [
{
"type": "vcs",
"url": "ssh2.sftp://example.org",
"options": {
"ssh2": {
"username": "composer",
"pubkey_file": "/home/composer/.ssh/id_rsa.pub",
"privkey_file": "/home/composer/.ssh/id_rsa"
}
}
}
]
{
"repositories": [{
"type": "composer",
"url": "https://example.org",
"options": {
"ssl": {
"local_cert": "/home/composer/.ssl/composer.pem"
}
}
}]
}
{
"repositories": [{
"type": "composer",
"url": "https://example.org",
"options": {
"http": {
"header": [
"API-TOKEN: YOUR-API-TOKEN"
]
}
}
}]
}
参考:https://getcomposer.org/doc/articles/authentication-for-private-packages.md