配置
全局配置
1 | composer config -g repo.packagist composer https://repo.huaweicloud.com/repository/php/ |
单独配置
1 | composer config repo.packagist composer https://repo.huaweicloud.com/repository/php/ |
取消配置
1 | composer config -g --unset repos.packagist |
刷新 composer.lock
1 | composer update nothing |
清空缓存
1 | composer clearcache |
出现问题一定要用
vvv
来查看日志,如果没有换源成功要看一下composer.json
里面是否存在prefer-source
,会影响到全局配置导致无法生效。
升级版本
1 | composer selfupdate |
其他源
提供商 | 地址 |
---|---|
aliyun | https://mirrors.aliyun.com/composer/ |
tencent cloud | https://mirrors.cloud.tencent.com/composer/ |
cnpkg | https://php.cnpkg.org |
sjtug | https://packagist.mirrors.sjtug.sjtu.edu.cn |
如果你想搭建自己的镜像源,可以看看 packagist-mirror 或者 ZComposer