Skip to main content
Last Reviewed: 2022-12-12

Add Contrib and Custom Code


This section describes how to replicate your selection of contributed modules and themes, and any custom modules or themes your development team has created in your new project structure.

Contributed Code

The goal of this process is to have Composer manage all the site's contrib modules, contrib themes, core upgrades, and libraries (referred to as contributed code). The only items from the existing site that should remain in the Git repository are custom code, custom themes, and custom modules that are specific to the existing site.

Modules and Themes

Your site should already be managing contributed modules and themes through Composer. Follow the steps below to migrate these items to a new site.

  1. Open the source site composer.json.

  2. Run a composer require command for each module and theme in the $DESTINATION directory:

You can require multiple packages in the same commands, if desired.

Other Composer Packages

If you added non-Drupal packages to your site via Composer:

  1. Run the command composer require to migrate each package.

  2. Use the following command to display the differences between the master and current composer.json:

Libraries

Libraries can be handled similarly to modules, but the specifics depend on how your library code was included in the source site. If you're using a library's API, you may have to do additional work to ensure that it functions correctly.

Custom Code

Manually copy custom code from the existing site repository to the Composer-managed directory.

Modules and Themes

settings.php

Additional Composer Configuration

Any additional Composer configuration that you have added to your site should be ported over to the new composer.json file. This can include configurations related to repositories, minimum-stability, or extra sections.

Use the diff command to get the information you need to copy:

Commit your changes as needed.

Push to the External Repository Master Branch

  1. Push to the master branch in the external repository:
  1. Confirm that the Continuous Integration workflow succeeds in committing your code changes to the Pantheon site.