1 全局模式(推荐):
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
2 单独项目使用
composer config repo.packagist composer https://mirrors.aliyun.com/composer/
扩展:
在项目里的composer.json里面添加
1 数组方式
[ ] 是数组方式,按照顺序查找
{ "repositories": [ { "type": "composer", "url": "https://mirrors.aliyun.com/composer/" }, { "type": "composer", "url": "https://packagist.org/" } ] }
2.对象方式
{ } 对象方式: 使用JSON对象表示法。但是,JSON键/值对应被视为无序,因此无法保证一致的行为
{ "repositories": { "foo": { "type": "composer", "url": "https://mirrors.aliyun.com/composer/" }, "packagist": { "type": "composer", "url": "https://packagist.org/" } } }