Centos multi-version php configuration multi-version composer

In the actual use of php projects, some projects often need to rely on different versions of composer, and it will be troublesome to switch versions each time. The method of configuring multiple composers is recorded here for future viewing and developer reference.

illustrate

Multiple versions of PHP are compiled and installed in the following directories, which are similar.

/usr/local/php/php5.6.29/
/usr/local/php/php7.2.4/

 

Here use php7 and 5.6 as an example reference, other versions can refer to this method.

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

 

Configure startup files

#Corresponding version php7

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 $*

#Corresponding version php5.6 (default)

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 $*

 

run permission

chmod +x /usr/local/bin/composer7
chmod +x /usr/local/bin/composer

 

Run the example

Configure China Mirror

composer7 config -g repo.packagist composer https://packagist.phpcomposer.com
composer config -g repo.packagist composer https://packagist.phpcomposer.com

Check the composer version

composer7 -V
composer -V

 

 

My blog will be moved and synchronized to Tencent Cloud + Community, and everyone is invited to join: https://cloud.tencent.com/developer/support-plan?invite_code=lqlbf51gy9ic

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325722606&siteId=291194637