Press "Enter" to skip to content

composer常用国内镜像源及全局设置

composer 中的源分为局部源以及全局源,更换全局镜像源不会影响局部的镜像源。

1、查看 composer 配置的命令

composer config -g -l

/////////////////////////////
[repositories.packagist.org.type] composer
[repositories.packagist.org.url] https://repo.packagist.org

[repositories.packagist.org.url] 这个为 composer 官方源地址

2、禁用https源地址检查命令

默认为 true,不建议修改

composer config -g secure-http false

3、修改镜像源

#cnpkg(每分钟)
composer config -g repos.packagist composer https://php.cnpkg.org

#Composer中文网(每分钟)
composer config -g repo.packagist composer https://packagist.phpcomposer.com

#上海交大(每80分钟)
composer config -g repos.packagist composer https://packagist.mirrors.sjtug.sjtu.edu.cn

#阿里云(每天:2点-4点)
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

#华为云(每天:0点-4点)
composer config -g repo.packagist composer https://repo.huaweicloud.com/repository/php/

#腾讯云(每天:0点-2点)
composer config -g repos.packagist composer https://mirrors.cloud.tencent.com/composer/

4、恢复默认源

composer config -g --unset repos.packagist

参考官方文档:Config – Composer (getcomposer.org)

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code