Tuesday 29 March 2022

How to install Switch Between Composer Version 1 and 2 in ubuntu

 How to install Switch Between Composer Version 1 and 2 in ubuntu

Install Composer

Link for reference : Download Link

-> Hits below command in open ubuntu terminal

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"


php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"


php composer-setup.php


php -r "unlink('composer-setup.php');"

->install composer globally hit below command

Command hits : sudo mv composer.phar /usr/local/bin/composer

->check composer version

Command hits : composer

Switching Versions

you can change the version using composer self-update command. 

if you want to switch composer 1 to composer 2 then you can hits below command

Hit command Name: composer self-update --2

if you want to switch composer 2 to composer 1 then you can hists below command

Hit command Name: composer self-update --1

Switching Specific Version

if you want to switch specific Versions. then hits below reference command

syntax : composer self-update (version name which you want to switch)

For Example

Hit command -> composer self-update 1.10.22


Hit Command -> composer self-update 2.1.3

Update and Revert Version

if you want to update composer version using command line

you can hit below command

Command Name : composer self-update

if you want to revert install version using command line

you can hit below command

composer self-update --rollback

Preview Version

The command below will allow you to get the pre-released version.

command name : composer self-update --preview

View Current Version 

if you want to check current version

Command name : composer


No comments:

Post a Comment

Thank You For Comment