Skip to main content

Manage Some Dependencies with Composer

Get your feet wet with Composer on WordPress or Drupal before going all in.


In this guide, you'll learn how to use Composer in small doses with WordPress and Drupal so you can work towards best practices achieved by more advanced implementations. This allows you to continue using Pantheon's one-click core updates in the Site Dashboard while managing non-core dependencies with Composer.

Before You Begin

Warning:
Warning

Partial Composer adoption for Drupal sites is not supported since Composer is used by core, meaning any change to composer.json or the vendor directory would result in massive merge conflicts when trying to update core via one-click updates in the Pantheon Site Dashboard. Composer with Drupal is an all or nothing proposition. To use Composer to manage Drupal sites, use the Build Tools or convert an existing Drupal site to Integrated Composer on Pantheon methods.

  • Set the site's connection mode to Git within the Site Dashboard or via Terminus:

  • Create a local clone of your site code, and navigate to it in your terminal

Initialize and Configure Composer

Use the init command to create a composer.json file that includes the appropriate package repository, then configure installation paths for dependencies like plugins and modules:

Anything you aren't managing with Composer is installed and maintained using the standard techniques such as using the WordPress or Drupal admin interfaces. Continue applying one-click core updates from Pantheon in the Site Dashboard.

Require Dependencies

Use the require command to add new dependencies to your project, such as libraries or themes. This command modifies your composer.json file by including the specified dependency and it's compatible version.

Note that Pantheon does not run composer install on the platform, so you need to install and commit the dependencies.

Next Steps

If your use case doesn't require the more advanced Build Tools method, continue using Composer to manage any number of your non-core dependencies while preserving Pantheon's one-click core updates. This is only supported for Drupal and WordPress.

If you're ready to learn best practices for Composer on Pantheon, follow the Build Tools guide.