Setting up an environment to test Drupal patches and merge requests

Last updated on
22 March 2024

This documentation needs work. See "Help improve this page" in the sidebar.

Shorter URL to this page: drupal.org/tools

Much (but not all) of the work in the Drupal community involves improving the software for Drupal core and contributed projects (themes, modules, and distributions). If you want to contribute to improving the software, you will need to have a way to run the latest development version of Drupal, with software "patches" (proposed software changes) installed. This page will get you set up.

There are two recommended options, in order of complexity:

  1. Use a site that is set up expressly for testing Drupal patches, or an online preview for a merge request. This option is fine if your current aim is to test patches or merge requests that others have made; it is not as suitable if you want to develop patches or merge requests yourself. Besides being the simplest option to set up, another advantage is that you can set up a testing site, and several people can interact with the same site to collaborate on testing. This option is described below.
  2. Set up a "local development environment", which includes a web server running on your local computer (desktop or laptop), so you can install Drupal there with patches. This option also allows you to develop patches yourself and submit them for consideration, but because the Drupal site is running only on your local computer, it is not possible to have others look at your site unless they happen to be physically sitting next to you or you get on Zoom or similar environment and share your screen. This option is described below.

Of course, you can choose to set up a local development environment, and still occasionally spin up a particular patch in a Drupal testing site when you want to show it to others! You don't have to stick with just one of these options.

Setting up an online testing environment (with or without patches)

The following sites allow you to use to test Drupal core and contributed projects (modules, themes, and distributions). You can test a particular released version, a development version, or a "patched" version (development version with a patch from an issue applied). Available sites:

To use one of these sites:

  1. Go to the main URL of the site.
  2. If you are testing a patch for a contributed project, type the project name in the Project field. Otherwise, type Drupal core.
  3. Choose the version that you want to test. Released versions (9.0.1, 2.0.1, etc.) are listed first, and development versions (9.1.x, 8.x-2.x, etc.) last.
  4. Add additional modules and themes to be installed; compatible versions will automatically be selected.
  5. Under "Advanced", paste links to the Drupal core patch(es) that you want to test, which must be on the primary project and must be patch files that were uploaded to a drupal.org issue.
  6. Launch and wait for your site to be created. Once it is ready:
    • You will be able to log in as "user 1" administrator using the user name / password: admin / admin.
    • The site email address is admin@example.com.

Using an automatic Merge Request preview online site

Drupal Core issues (and some contributed project issues) that use merge requests will generate automatic links to set up a test site, which use "Tugboat". If a merge request has an automatic preview available, a Preview link will be shown under the merge request area in the issue; click the link to initiate the test site. For more information, see Using live previews on Drupal Core merge requests. As with patch testing sites:

  • You will be able to log in as "user 1" administrator using the user name / password: admin / admin.
  • The site email address is admin@example.com.

If you want to test a merge request on an issue that does not have a Preview link, you may also use the Chrome or Firefox browser extension provided by the remote development environment DrupalPod. Or use one of the remote development environment or local development environment options.

Using a remote development environment

DrupalPod

This project allows you to work on Drupal contributions with a familiar setup of a "normal" Drupal website. This option does not require any changes to your personal or work-provided computer because it is all running in the cloud.

Start Drupal contributions with 1 click using Gitpod. Follow the instructions on DrupalPod Getting Started page including a Demo Video of DrupalPod on Drupal Core Contribution Mentoring's YouTube Channel.

Project URL: https://github.com/shaal/DrupalPod

Using a local development environment

Install the environment with DDEV

If you are not currently at a large contribution event, here are the steps to follow to install the necessary software for a local development environment:

  1. Install DDEV.
  2. Get latest version of Drupal by following he steps on the Version control instructions page for the Drupal core project to clone Drupal into a new directory.
  3. From the Drupal root directory, generate DDEV configuration to serve project:
    ddev config --project-type drupal10 --docroot .
    This will create a new DDEV project configured to host a Drupal application. DDEV will store the generated configuration in a new .ddev subdirectory.
  4. Clone the example.gitignore file and rename it to .gitignore, so that you don't accidentally commit your locally installed packages.
  5. Add .ddev and .gitignore to the new .gitignore file.
  6. Start the DDEV container:
    ddev start
  7. Run the following command to download the external dependencies for the Drupal core software:
    ddev composer install
  8. Install Drush:
    ddev composer require drush/drush
  9. Install Drupal:
    ddev drush site:install -y
  10. Launch your new Drupal site:
    ddev launch
  11. Generate a one-time login link for the administrator account (user id #1):
    ddev drush user:login

Once you have installed DDEV, if you want to create a new Drupal site for testing, you can follow these instructions again (skipping steps 1 and 2, since you will already have Docker and DDEV installed).

If you already have a local development environment

If you already have a web server, PHP, and database installed on your local computer that satisfy the requirements for the latest development of Drupal, know how to install Drupal, and know where your web root is, follow these steps to create a new Drupal site for testing a patch:

  1. Make sure you have both Composer and Git installed on your computer.
  2. Set up Git for use in the Drupal project.
  3. Follow the steps on the Version control instructions page for the Drupal core project to clone Drupal into a new directory under your web root. Change to that directory.
  4. Rename the example.gitignore file to .gitignore, so that you don't accidentally commit your locally installed packages. 
  5. Use the git apply command to apply the patch you want to test.
  6. From the Drupal root directory, run the following command to download the external dependencies for the Drupal core software:
    composer install
  7. Set up a database for your Drupal site, and install Drupal.

Other ways to set up a development environment

There are many more options for setting up development environments. Although we recommend the above methods, you may find the local server setup documentation section and developer tools section useful to browse.

Other Useful Tools

Drush

Install - drush.org/install/

Drupal.org CLI

https://github.com/mglaman/drupalorg-cli

Tags

Help improve this page

Page status: Needs work

You can: