Create a Drupal Site Using a Drupal Distribution
Learn how to create a site using a Drupal distribution.
Distributions are pre-made packages that you can use to simplify creating and setting up a Drupal website. Drupal distributions are exceptionally helpful if you want to create a website, but don't want to build it from scratch.
Review the documentation provided with the community distribution before following the steps below.
Prepare
Review our documentation on Git, Composer, and Terminus, and install and configure them on your local computer. Pantheon requires Composer 2 at minimum.
Mac users can use Homebrew to install Git, Composer, and PHP, along with their required dependencies. Restart the shell or terminal environment after entering the following command:
brew install git composer phpWindows users can install Composer and Git, and may need to install XAMPP or similar to satisfy some dependencies.
Create a Site Based on an Empty Upstream
There are two ways to create an empty Upstream site: via the Pantheon Dashboard and via Terminus.
Via the Pantheon Dashboard:
- Use the Empty Site Upstream
Via Terminus:
terminus site:create my-new-site "My New Site" empty
Create the Project
Use the documentation provided with the Drupal distribution to run the recommended Composer create-project command.
You can review a list of commonly used distributions on the Drupal Distributions page.
Add Files and Folders
Now you're going to copy files and folders from the Pantheon GitHub repository for use in your project.
Clone https://github.com/pantheon-upstreams/drupal-composer-managed into another folder.
In the code samples included below, [
drupal-composer-managed-path] should be replaced with the location of the cloned repository. In addition, they assume the commands are being run from the folder created from thecreate-projectcommand.Copy the
upstream-configurationfolder to your site:cp -r /drupal-composer-managed-path/upstream-configuration .Copy the
pantheon.upstream.ymlfile to your site:cp /drupal-composer-managed-path/pantheon-upstream.yml .Create an empty
configfolder:mkdir -p config .
Update Composer Settings
Add/modify the settings in composer.json as follows, replacing the Drupal values with the latest version:
Add the
upstream-configurationpath repository:composer.json"repositories": [ { "type": "composer", "url": "https://packages.drupal.org/8" }, { "type": "path", "url": "upstream-configuration" }],Include the following in the
requiresection:composer.json"require": { "pantheon-upstreams/upstream-configuration": "dev-main", "pantheon-systems/drupal-integrations": "^9", "drush/drush": "^11 || ^12" },Add
pantheon-systems/drupal-integrationsand Quicksilver scripts (optional) toextra:composer.json"extra": { "drupal-scaffold": { "locations": { "web-root": "./web" }, "allowed-packages": [ "pantheon-systems/drupal-integrations" ], "file-mapping": { "[project-root]/.editorconfig": false, "[project-root]/pantheon.upstream.yml": false, "[project-root]/.gitattributes": false } }, "installer-paths": { "web/core": ["type:drupal-core"], "web/libraries/{$name}": ["type:drupal-library"], "web/modules/contrib/{$name}": ["type:drupal-module"], "web/profiles/contrib/{$name}": ["type:drupal-profile"], "web/themes/contrib/{$name}": ["type:drupal-theme"], "drush/Commands/contrib/{$name}": ["type:drupal-drush"], "web/modules/custom/{$name}": ["type:drupal-custom-module"], "web/profiles/custom/{$name}": ["type:drupal-custom-profile"], "web/themes/custom/{$name}": ["type:drupal-custom-theme"], "web/private/scripts/quicksilver/{$name}/": ["type:quicksilver-script"] }, "composer-exit-on-patch-failure": true, "patchLevel": { "drupal/core": "-p2" } },Add
autoload.classmap:composer.json"autoload": { "classmap": [ "upstream-configuration/scripts/ComposerScripts.php" ] },Add these
scriptsandscripts-descriptionsections:composer.json"scripts": { "pre-update-cmd": [ "DrupalComposerManagedComposerScripts::preUpdate" ], "upstream-require": [ "DrupalComposerManagedComposerScripts::upstreamRequire" ] }, "scripts-descriptions": { "upstream-require": "Add a dependency to an upstream. See https://docs.pantheon.io/create-custom-upstream or information on creating custom upstreams." },
Update settings.php
Add the following to your /web/sites/default/settings.php file.
include __DIR__ . "/settings.pantheon.php";Initialize, Push, and Test
Initialize the git repo and commit everything:
git init -b master git commit -am "Initial commit"Add the Pantheon repository as a remote:
git remote add origin [pantheon_remote]If you need to get
pantheon_remote, use Terminus:terminus connection:info --field=git_url [site].devForce push to Pantheon
masterbranch:git push origin master -fInstall your site in the dev environment and test that everything works.