Laravel How to Swap Between Different Composer Versions

Hello artisans, today I'll show you how to swap between different composer versions mean we'll switch the composer version from the command line. Sometimes we have a project with composer versions 1 and 2. Then what we'll do? So, today's tutorial is about that.

Note: Tested on Laravel 9.19.

Fire the below command to switch back to version 1.

composer self-update --1

And if we install any dependency then it'll install in version 1 composer.

And we can use the same command to switch into the version 2.

composer self-update --2

And we can say that all the dependency will install in version 2.

Not only that we can also change the specific version of composer From the below command.

composer self-update 1.10.22
composer self-update 2.1.3

Updating the composer to the latest version, simply we've to run the "self-update" command.

For update the composer to the latest version, we've to simply run the "self-update" command as like as below.

composer self-update

And for revert back to the previous version we need to fire the below command.

composer self-update --rollback

That's it for today. I hope you've enjoyed the tutorial. Thanks for reading. 🙂