Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Updating the DrupalEasy.com codebase to use Composer 2

Parent Feed: 

After teaching folks how to use Composer effectively over the past couple of years, I figured it was time for me to (finally) update DrupalEasy.com to use Composer 2. I figured it would be a pretty easy process, and I was correct.

I've had a few people ask me about the process, so I thought I'd write up what it took to update this site to Composer 2. First a few facts about this codebase:

  • Dependencies are committed to the project Git repository.
  • The site is hosted on Pantheon
  • I use DDEV for local development.

So, the first step, prior to updating to Composer 2, is to ensure all plugins are ready for Composer 2. In this case of the DrupalEasy.com codebase, there were three Composer plugins to review:

  1. composer/installers - compatible with Composer 2 starting with 1.9.0
  2. cweagans/composer-patches - compatible with Composer 2 starting with 1.7.0
  3. topfloor/composer-cleanup-vcs-dirs - the "dev-composer-2" branch is compatible with Composer 2

So, while still using Composer 1, I did the following (on my local, of course):

composer update composer/installers
composer update cweagans/composer-patches

Then I manually edited the composer.json file and changed the version constraint for topfloor/composer-cleanup-vcs-dirs to: "topfloor/composer-cleanup-vcs-dirs": "dev-composer-2" 

Then,

composer update topfloor/composer-cleanup-vcs-dirs

Once that was done, I updated my .ddev/config.yaml file to use:

composer_version: "2"

After restarting DDEV, I verified that all was well by updating a couple of Drupal modules (non-security related maintenance releases) before committing all changes and pushing up to Pantheon.

Obviously, the most important step is to ensure all of your Composer plugins are compatible with Composer 2 - just remember to do this prior to updating to Composer 2!

Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web