如何用composer引用github
时间: 2024-03-21 15:32:47 浏览: 57
1. 在项目根目录下创建 composer.json 文件。
2. 在 composer.json 文件中添加如下代码:
```json
{
"require": {
"github-username/repository-name": "version-tag"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/github-username/repository-name.git"
}
]
}
```
其中,`github-username` 是 Github 的用户名,`repository-name` 是仓库名称,`version-tag` 是你想要引用的版本号或分支名。
3. 执行 `composer install` 命令安装依赖包。
如果你想要引用 Github 上的私有仓库,还需要在 `composer.json` 文件中配置 Github 的认证信息:
```json
{
"config": {
"github-oauth": {
"github.com": "your-github-token"
}
}
}
```
其中,`your-github-token` 是你的 Github 访问令牌。你可以在 Github 设置页面中生成一个访问令牌,然后将其添加到 `composer.json` 文件中。
阅读全文
相关推荐


















