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.
Composer packages
Copy your package list from the
requiressection of the existing site'scomposer.jsonand add it to the new site'scomposer.json.If the existing
composer.jsondefines additional repositories or patches, copy those over too. Take care not to overwrite theupstream-configurationpackage and repository.If the old site has custom patches in its codebase, make sure to copy those over as well.
Run
composer updateto have Composer create acomposer.lockfile with all versions and dependencies:composer updateRun the
git statuscommand to confirm that all changed files have names that start withcomposer..Add other folders to
.gitignoreuntilgit statusonly shows the Composer files being modified:git statusAdd and commit the changed Composer files to Git:
git add composer.*; git commit -m "Add composer packages"
Custom Code
Complete the steps below if you have custom code that you would like to move to your new site.
Manually copy custom code from the old site to the corresponding Pantheon site directory and commit the changes.
Update the new
.gitignorefile to keep it aligned with the current site to avoid potential issues in the future.
Install Libraries with drupal-library
Do not add anything to web/libraries if you want to install libraries using Composer via a drupal-library project. You must use Composer to install your libraries.
Add each directory to be allowed (not ignored) by
.gitignoreif you commit libraries directly toweb/libraries.- For example, to commit a
favorite-librarydirectory, add it and each directory to.gitignore.
- For example, to commit a
Run the
git addcommand:.gitignore!/web/libraries/favorite-library !/web/libraries/other-favorite-library
You can remove the web/libraries line from the .gitignore file if you do not plan on adding any libraries with Composer in the future. This might lead to builds failing in the future if you or another developer use Composer to add a library later on.
Modules and Themes
Follow the steps below if you want to move modules and themes to your new site.
Navigate to the Pantheon site directory.
Copy modules from the local directory of the old platform site:
cp -R ../FORMER-PLATFORM/modules/custom web/modules git add web/modules/custom git commit -m "Copy custom modules"Copy themes from the local directory of the old platform site:
cp -R ../FORMER-PLATFORM/themes/custom web/themes git add web/themes/custom git commit -m "Copy custom themes"Copy any other custom code you need from your old platform site.
settings.php
Your existing site may have customizations to settings.php or other configuration files.
Copy the existing
settings.phpto the Pantheon site and remove the$databasesarray if it exists.Ensure that everything in the Pantheon settings.php is included.
Confirm that the
settings.phpfile on the Pantheon D9 site:- Has one
$settings['container_yamls'][] - Contains no duplicates
- Contains
include __DIR__ . "/settings.pantheon.php";
- Has one
Configuration
Complete the steps in this section to copy exported configuration settings from the original site to your new Pantheon site.
Navigate to your Pantheon site.
Run the following commands:
mkdir config cp -R ../FORMER-PLATFORM/<config folder location> config/ git commit -m "Add site configuration."