Skip to main content
Last Reviewed: December 13, 2022

Add or Remove Individual Site Dependencies

Learn how to add or remove an individual site dependency.


This sections provides information on dependency requirements and how to add or remove individual site dependencies.

Composer require and require dev Sections

It's important to understand how require and require dev are used on the Pantheon platform.

Composer require Section

Drupal modules / themes and WordPress plugins / themes should always be in the require section, not the require-dev section. Dependencies in the require section are pushed to all Pantheon environments.

Composer require dev Section

You should use the require-dev section for dependencies that are not a part of the web application but are necessary to build or test your project. Some examples are php_codesniffer and phpunit. Dev dependencies are deployed to Pantheon Dev and Multidev environments, but not to Test and Live environments.

Third-party dependencies, such as modules / plugins and themes, are added to the project via composer.json. The composer.lock file keeps track of the exact version of dependency. Composer installer-paths are used to ensure the dependencies are downloaded into the appropriate directory.

Select Dependencies Locally

When running composer install on a local clone of your Pantheon site's repository, you can use the --no-dev option to install the dependencies that will be installed on the Pantheon Test and Live environments. Do not include this option to install the dependencies that will be installed on Dev and Multidev environments on Pantheon. The --no-dev option has no effect on what is written to the composer.lock file, and therefore does not change the behavior of your site on Pantheon. This option is only relevant to local testing.

Add a Dependency to an Individual Site

  1. Clone the Git repository from the Pantheon site's dashboard.

  2. Run composer install:

    composer install
  3. Add a new dependency locally:

    composer require drupal/pkg-name
  4. Commit composer.json and composer.lock and push the changes.

    git add composer.json composer.lock && git commit -m "added composer.json and composer.lock" && git push
    • Pantheon will run Composer, build artifacts, and deploy the changes to your Dev or Multidev environment. You can now deploy the changes from the updated Dev environment to the Test and Live environments.
  5. Complete the steps to commit Dev changes to Test and Live through your Pantheon dashboard or with Terminus env:deploy.

Remove Individual Site Dependencies

You can remove site dependencies if they are no longer needed. You should use caution when removing individual site dependencies. You can cause problems with your site if you decide you no longer need a module but leave it installed, and then remove site dependencies.

  1. Clone the database from Live to all other environments before continuing.

  2. Ensure that all modules in the package have been uninstalled. You can uninstall modules in the Drupal admin dashboard, or from the command line with Terminus:

    terminus drush site.live -- pm:uninstall module1 module2
  3. Remove the dependency locally:

    composer remove drupal/pkg-name
  4. Commit composer.json and composer.lock and push the changes.

    • Pantheon will run Composer, generate build artifacts, etc.

More Resources