Using Both Composer 1 and Composer 2

Composer 2 has been released with several great features and improvements! Best of all it's (mostly) backward-compatible with Composer 1. The one issue you're most likely to encounter when upgrading to Composer 2 is having Composer plugins that don't support this newer version yet.

The ideal solution would be upgrading those plugins to newer versions (or submitting a feature request to the plugin developers to support Composer 2). But if that's not feasible you can actually co-install both Composer 1 and Composer 2 by following these steps:

Step 1: Install Composer 1 separately

Assuming you already have Composer installed, this will create a copy of it called composer1:

sudo cp `which composer` /usr/local/bin/composer1 && sudo composer1 self-update --1

Step 2: Upgrade Composer to v2

If you haven't already upgraded your main composer program to v2 you can do so with this command:

composer self-update --2 # You might need to run this with "sudo"

At this point, you'll have two commands available on your machine:

  • composer - The latest version of Composer (v2)
  • composer1 - A separate copy of Composer (v1)

Step 3: Add composer2 alias (optional)

If you'd also like to have composer2 available as a command, simply create the following symlink:

sudo ln -s `which composer` /usr/local/bin/composer2

Now you have three commands at your disposal:

  • composer - The latest version of Composer (v2)
  • composer1 - A separate copy of Composer (v1)
  • composer2 - A symlink to composer

Was this helpful?

About Colin O'Dell

Colin O'Dell

Colin O'Dell is the Director of Technology at Unleashed Technologies, a web and hosting firm based in Maryland. In addition to being an active member of the PHP League and maintainer of the league/commonmark project, Colin is also a PHP docs contributor, conference speaker, and author of the PHP 7 Migration Guide.