方法一 命令行
composer config -g repo.packagist composer https://packagist.phpcomposer.com
方法二修改json文件
composer config repo.packagist composer https://packagist.phpcomposer.com 会自动添加 "repositories": { "packagist": { "type": "composer", "url": "https://packagist.phpcomposer.com" } } laravel的例子 { "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" } } }