Skip to content

Instantly share code, notes, and snippets.

@pyrello
Last active October 24, 2023 07:04
Show Gist options
  • Save pyrello/920abbcf19d4fa28383615c7954e3b71 to your computer and use it in GitHub Desktop.
Save pyrello/920abbcf19d4fa28383615c7954e3b71 to your computer and use it in GitHub Desktop.
Drupal core development easy local setup

Initial setup

  1. Install DDEV (if not already installed): https://ddev.readthedocs.io/en/stable/users/install/ddev-installation/
  2. Ensure that you have a ssh key setup with Drupal.
  3. Install joachim-n/drupal-core-development-project:
composer create-project -n joachim-n/drupal-core-development-project drupal-core-dev && cd drupal-core-dev
  1. Add DDEV to the project:
ddev config --project-type=drupal10 --docroot=web
  1. Install ddev/ddev-selenium-standalone-chrome:
ddev get ddev/ddev-selenium-standalone-chrome

Core issue patch workflow

Initial setup for each issue

  1. Navigate to the drupal repo and get your bearings. Git status should indicate that you have head branch (currently 11.x) checked out
cd repos/drupal && git status
  1. Open the issue you want to work on. For this, I'll use https://www.drupal.org/project/drupal/issues/3208766
  2. If there isn't already an issue fork, you may need to create one
  3. If there isn't already an MR, you don't need to create one until you are ready for feedback or core's CI to run
  4. Click "Show commands" next to the issue fork
  5. Copy/paste the commands under "Add & fetch this issue fork’s repository" into your terminal and run them
  6. Find the issue fork branch you want to work on and copy/paste the command under "Check out this branch" into your terminal and run it
  7. At this point you should be ready to write code, spin up a Drupal site for manual testing, or run automated tests

Ongoing development

  1. Pull changes
git stash -m "3208766 Something something." && git pull --rebase && git stash apply
  1. If your git stash apply command didn't apply cleanly, you may need to resolve conflicts.
  2. Commit and push your changes
git add . && git commit -m "Updated the something something so that is now does something something." && git push
  1. Note that the Drupal core CI runs every time you push to it and the process takes ~40-60 minutes and uses up resources that the Drupal Association has to pay for, so try to be mindful about how often you are pushing. You can commit often and push when you are ready to see what happens with tests or get feedback from the community.

Running tests

ddev exec -d /var/www/html/web "../vendor/bin/phpunit -v -c ./core/phpunit.xml.dist ./core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php"

From: https://github.com/ddev/ddev-selenium-standalone-chrome#use

PhpStorm configuration

  • I recommend the DDEV integration plugin.

Suppress indexing of symlinked web/core and "Multiple implementations exist" warnings

  • Settings > Directories
  • Click caret next to web folder to expand
  • Click core folder to select
  • Next to "Mark as:" click "Excluded
  • Apply

Xdebug

  • It helps to turn on xdebug and trigger it to run first so it will register a server
  • When running FunctionalJavascript tests, a server instance is created and runs at http://web. It's helpful to also trigger Xdebug to run during a test to also register that as a server
  • PHP > Servers
  • For each server you have registered, navigate to repos/drupal under Project files. Add /var/www/html/web under "Absolute path on the server". Click somewhere else to get "Apply" to be available and then click "Apply"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment