Composer 国内加速,修改镜像源
为什么慢?
执行 composer 各种命令的时候,默认是去 composer 官方镜像源获取需要安装的具体软件信息
默认源地址在国外,从国内访问的速度肯定比较慢
如何修改镜像源
目前国内的有哪些composer源呢
- https://packagist.laravel-china.org
- https://packagist.phpcomposer.com
- https://mirrors.aliyun.com/composer/
- https://mirrors.cloud.tencent.com/composer/
本文以 laravel china 的国内镜像源为例。
当前laravel项目怎么配置composer源呢?只需要加载composer.js中最后 修改源的路径就行了
"repositories": {
"packagist": {
"type": "composer",
"url": "https://packagist.phpcomposer.com"
}
},
a). 配置只在当前项目生效
composer config repo.packagist composer https://packagist.laravel-china.org
composer config --unset repos.packagist # 取消当前项目配置
b). 配置全局生效
composer config -g repo.packagist composer https://packagist.laravel-china.org
composer config -g --unset repos.packagist # 取消全局配置
c). 使用第三方软件快速修改、切换 composer 镜像源
crm composer registry manager
安装 crm
composer global require slince/composer-registry-manager
列出当前可用的所有镜像源
composer repo:ls
composer --------- https://packagist.org
phpcomposer ------ https://packagist.phpcomposer.com
composer-proxy --- https://packagist.composer-proxy.org
laravel-china ---- https://packagist.laravel-china.org
使用 phpcomposer 镜像源
composer repo:use laravel-china