1. 全局换源
# 禁用https源地址检查命令
composer config -g secure-http false
# 修改镜像源 composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ # 查看全局的配置信息(是否修改成功) composer config -g -l
2. 局部换源(项目内)
在项目的composer.json中添加如下代码:
{ "repositories": [ { "type": "composer", "url": "https://mirrors.aliyun.com/composer/" //阿里云源 }, { "type": "composer", "url": "https://repo.packagist.org" //默认源 }, }
3. 常用命令
1. 查看全局配置: composer config -g -l 2. 恢复默认源: composer config -g --unset repos.packagist
4. 常用国内源
composer 中文网提供的中国全量镜像:
https://packagist.phpcomposer.com https://php.cnpkg.org
阿里云composer镜像:
https://mirrors.aliyun.com/composer/
腾讯云composer镜像:
https://mirrors.cloud.tencent.com/composer/