Composer version 2

We updated all our D8 and D9 sites to use Composer 2. Composer 2.0 was released on 24 October, 2020.

After we upgraded Composer on our development environment, we checked and found our projects only complained about one or two plugins. For some of the sites we needed to update cweagans/composer-patches to version ^1.7.0. For some we needed to update composer/installers to version ^1.9. For the sites we Composerized using the Grasmash composerize-drupal plugin we had to remove the plugin and all the packages that came with it (they are no more needed for the site to work once the site got Composerized).

As simple as these steps and our sites were working with Composer 2. Composer 2 is so much faster and uses far less memory. It's a big relief to remove Composer wait time from our development process not to talk of making sure there is enough high memory for Composer on our machines.

Here are some info from the official release:

Performance improvements

We overhauled pretty much everything from the protocol used between Composer and packagist.org to the dependency resolution, including downloading files in parallel using curl and constraint evaluation optimizations. This leads to massive improvements in terms of both speed and memory usage. The difference depends on your use case, so while I've seen reports of improvements of over 50% to both in some projects, I cannot put an exact number on it. But I am sure you will be positively surprised if you haven't tried Composer 2 yet.

As a side note to this, require/remove and partial updates are now much faster because Composer will now only load the metadata of the packages which are being changed.

Composer 2 release announcement
Time for initial update + install (bootstrapped project, empty cache) shows roughly 60% less time used by Composer 2 with ext-curl enabled / Image credit: Official release announcement

 

Last updated: May 05, 2021
Tags