Upgrading To Composer 2 on Ubuntu

As we all know that Composer 2 was released on the 24th of October 2020. I have decide to share a guide on how to upgrade your composer on your local server to make the most of all the great benefits the new version brings.

In other to update Composer itself to the latest version, run the self-update command. It will replace your composer.phar with the latest version.

php composer.phar self-update

If you would like to instead update to a specific release specify it by including the version number:

php composer.phar self-update 1.0.0-alpha7

If you have installed Composer for your entire system, you may have to run the command with root privileges

sudo -H composer self-update

This command might not be available if composer was not installed as a PHAR file on your system, which is often caused when composer was installed with an operating system package manager.