php項目在實際使用中,每每有些項目須要依賴不一樣版本的composer,每次切換版本會比較麻煩。這裏記錄配置多composer的方法,方便往後查看及開發者參考。php
PHP多個版本編譯安裝在如下目錄,類同。bash
/usr/local/php/php5.6.29/ /usr/local/php/php7.2.4/
這裏使用php7及5.6做爲示例參考,其餘版本均參考此方法都可。php7
cd /usr/local/php/php7.2.4/bin/ curl -sS https://getcomposer.org/installer | ./php cd /usr/local/php/php5.6.29/bin/ curl -sS https://getcomposer.org/installer | ./php
#對應版本 php7composer
vi /usr/local/bin/composer7
#!/bin/bash export PATH=$PATH:/usr/local/php/php7.2.4/bin/ php /usr/local/php/php7.2.4/bin/composer.phar $*
#對應版本 php5.6 (默認)curl
vi /usr/local/bin/composer
#!/bin/bash export PATH=$PATH:/usr/local/php/php5.6.29/bin/ php /usr/local/php/php5.6.29/bin/composer.phar $*
chmod +x /usr/local/bin/composer7 chmod +x /usr/local/bin/composer
配置中國鏡像url
composer7 config -g repo.packagist composer https://packagist.phpcomposer.com composer config -g repo.packagist composer https://packagist.phpcomposer.com
查看 composer 版本spa
composer7 -V composer -V
個人博客即將搬運同步至騰訊雲+社區,邀請你們一同入駐:https://cloud.tencent.com/developer/support-plan?invite_code=lqlbf51gy9iccode