#进入安装目录
cd /usr/local/bin
#下载并安装
sudo curl -s https://getcomposer.org/installer | sudo php
#添加执行权限
sudo chmod a+x composer.phar
#加入全局命令
mv composer.phar /usr/local/bin/composer
#查看版本号
composer --version
全局配置镜像,以下为阿里云镜像配置命令。
composer config -g repos.packagist composer https://mirrors.aliyun.com/composer/
局部换源(当前项目有效)
{
"repositories": [
{
"type": "composer",
"url": "http://packages.example.com" //第一个源
},
{
"type": "composer",
"url": "http://packages.example.com" //第二个源
},
}
#把默认的源给禁用掉
composer config -g secure-http false
#使用阿里源
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
#查看配置
composer config -g -l