Authentication for Privately Repositories in Composer
composer:2.3.7
在一些專案裡,可能會用到一些公司或個人的 Private Repository,因此在進行套件更新時,就會需要一些認證才能繼續動作。
Composer 提供了透過 auth.json
進行認證的功能,方便在需要認證的情境使用。
Type | Generated by Prompt? |
---|---|
http-basic | yes |
Inline http-basic | no |
HTTP Bearer | no |
Custom header | no |
gitlab-oauth | yes |
gitlab-token | yes |
github-oauth | yes |
bitbucket-oauth | yes |
Basic Usage
Github Example by http-basic
{
"http-basic": {
"github.com": {
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD"
}
}
}
Github Example by github-oauth
{
"github-oauth": {
"github.com": "token"
}
}
Notice:
auth.json
跟composer.json
一樣,擺在專案根目錄底下就可以了。