composer 下载包慢的解决方法
方法一: 修改 composer 的全局配置文件(推荐方式)
打开命令行窗口(windows用户)或控制台(Linux、Mac 用户)并执行如下命令:
composer config -g repo.packagist composer https://packagist.phpcomposer.com
方法二: 修改当前项目的 composer.json
配置文件:
打开命令行窗口(windows用户)或控制台(Linux、Mac 用户),进入你的项目的根目录(也就是 composer.json
文件所在目录),执行如下命令:
composer config repo.packagist composer https://packagist.phpcomposer.com
上述命令将会在当前项目中的composer.json
文件的末尾自动添加镜像的配置信息(你也可以自己手工添加):
"repositories": { "packagist": { "type": "composer", "url": "https://packagist.phpcomposer.com" } }
以 laravel 项目的composer.json
配置文件为例,执行上述命令后如下所示(注意最后几行):
{ "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "type": "project", "require": { "php": ">=5.5.9", "laravel/framework": "5.2.*" }, "config": { "preferred-install": "dist" }, "repositories": { "packagist": { "type": "composer", "url": "https://packagist.phpcomposer.com" } } }
OK,一切搞定!试一下composer install
来体验飞一般的速度吧!
(转载请注明花儿为何那样红博客)