Running Composer 2 alongside Composer 1
Composer 2.0 launched in October of last year and you really should be using it. It's much faster than version 1.x.
I'm using Mac OS so that' what I'll be referencing here. The setup should work everywhere but you'll have to adjust the paths and commands as needed
Upgrading to 2.0 can be done quickly and easily by running
composer self-update --2.
But running Composer at 2.0 also means your packages and plugins should support Composer's new plugin architecture. If you're working on an older codebase and updating your dependencies simply isn't an option, you'll need Composer 1.x to install the project.
Downgrading from 2.x to 1.x can be done just as easily as upgrading: run
composer self-update --1 and you're back on the latest 1.x release. But if you need both versions somewhat regularly, downgrading and upgrading again each time is probably not the best solution.
Running both versions
In the setup I'm using right now, I'm running both versions alongside each other. I have
composer with is the latest and greatest and
composer1 which is the last 1.x release. Here how to do that.
First, we download a new copy using the install script you can find here. Then we move the new
composer.phar file to
/usr/local/bin but we also rename it in the process:
> sudo mv composer.phar /usr/local/bin/composer1 > composer1 self-update --1
That gives us both options:
> composer --version Composer version 2.0.9 2021-01-27 16:09:27 > composer1 --version Composer version 1.10.20 2021-01-27 15:41:06