Information for: DEVELOPERS   PARTNERS

Using Composer with Acquia products

Composer is an open-source package management tool for PHP applications and a core part of Drupal 8+ development workflows. Composer 1 was released in 2016 and Composer 2 was released in October 2020.

Composer 2 has many significant new features and performance improvements over Composer 1. The Composer maintainer has stated that Composer 1 is now effectively end-of-life. Acquia recommends that all customers upgrade to Composer 2 as soon as possible.

Given that the Composer 2 upgrade process is not backwards compatible for all applications and Acquia products either provide or depend on Composer in varying capacities, Acquia provides this guide to assist with the transition to Composer 2.

What are the benefits of Composer 2?

Compared to Composer 1, Composer 2 is faster in terms of magnitude and resource-efficient in terms of memory and CPU. Composer 2 achieves this performance out of the box, without requiring global plugins (such as Prestissimo or Composer Drupal Optimizations for Composer 1). Besides being faster, this also makes it more stable in container-based environments, such as Docker and Acquia Cloud IDE.

What is the status of the Composer upgrade in relation to Acquia products?

  • All Acquia products that provide Composer have been upgraded to provide Composer 2 by default.
  • All Acquia products that depend on Composer have been upgraded to support or require Composer 2. This is part of Acquia’s ongoing efforts to ensure Acquia products and services are secure, reliable, and scalable.

Which Acquia products provide Composer?

The following products provide Composer as a global, pre-installed, command-line (CLI) tool:

  • Acquia Pipelines:

    This product supports only Composer 1. You’ll be notified when Pipelines starts supporting Composer 2 and you’ll get time to migrate your applications before Composer 2 is made the default.

  • Acquia Cloud IDE:

    This product has already been upgraded to provide Composer 2 by default. This means that if your application calls the composer command, Composer 2 will run by default. You can change this behavior in the following ways:

    • Modify your application to call composer1 instead of composer, which forces the usage of Composer 1.
    • Download and install a specific version of Composer as part of your application and call that version of Composer explicitly using an absolute path to the Composer binary. Follow the instructions to download and install Composer, which can be done in any development environment (Acquia Cloud IDE, Acquia Pipelines) without sudo access as long as you install into your home directory.
    • Modify and export the PATH variable for your environment to place any installed version of Composer ahead of the default version, allowing you to use a specific Composer version without modifying your application. As an example, see how Cloud Hooks provided by BLT modify the PATH to use a locally-installed version of Composer and other binaries.

Which Acquia products depend on Composer?

The following products either require Composer to be globally installed in your development environment, or are dependent on your application being created through a compatible Composer version:

  • Remote Administration
  • Acquia BLT
  • Drupal packages
    • Lightning
    • Acquia DAM
    • Content Hub

Remote Administration

Remote Administration supports applications built with both Composer 1 and 2.

BLT

BLT 12.5.0 and later versions require Composer 2 to be installed globally. While Composer 1 may continue to work with BLT for the time being, it is no longer officially supported.

Note

BLT has no internal mechanism to specify which Composer version to use (that is, to specify the path of the Composer binary). If your application uses BLT but hasn’t yet been upgraded to support Composer 2, you’ll need to use a method described earlier to override the globally installed version of Composer (such as through a PATH export).

Drupal packages

Acquia’s Drupal modules and profiles, including Lightning, Acquia DAM, and Content Hub, support both Composer 1 and Composer 2.

How to upgrade to Composer 2?

Upgrading to Composer 2 consists of two steps:

  • Ensure that Acquia products or non-Acquia development environments that provide Composer are upgraded to provide Composer 2.
  • Ensure that any Acquia products, non-Acquia development tools, or Drupal applications that depend on Composer are upgraded to work with Composer 2.

Follow this guide to make your application compatible with Composer 2. You may need to upgrade, remove, or replace certain dependencies that conflict with Composer 2. Following this guide will modify your composer.lock file. Ensure that you commit the changes to this file to complete the upgrade.