Update Composer In Ubuntu
Jun 11, 2022, Originally published at techvblogs.com ・2 min read
Many legacy projects require a dependency that runs on the updated composer Version In Ubuntu.
This is an example of how to update the composer Version in Ubuntu.
In this short post, you’ll learn how to update the composer Version.
First, remove the composer. Run the following command:
sudo apt-get remove composer -y
Download the installer and composer setup:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --install-dir=/usr/bin --filename=composer
Switching Composer Version
To change to version one, run the self-update command and pass in the — 1 flag. This will change the composer to version one, and now you can install your dependencies.
composer self-update --1
Once you have installed your dependencies, you can now run the same command and pass in — 2 as the flag, which will switch back to composer version 2.
composer self-update --2
Switching Composer Specific Version
You can also change to a specific version with the minor version number, like below.
composer self-update 1.10.22
composer self-update 2.1.3
Revert Composer Version
To revert to the previous version, pass in the — rollback.
composer self-update --rollback
Preview Composer Version
The command below will allow you to get the pre-released version for anyone interested in using the preview version.
composer self-update --preview
Thank you for reading this blog.