Skip to content

Instantly share code, notes, and snippets.

@gnuget
Last active May 27, 2021 04:27
Show Gist options
  • Save gnuget/1933d7500f0aacf1c98b918111f55825 to your computer and use it in GitHub Desktop.
Save gnuget/1933d7500f0aacf1c98b918111f55825 to your computer and use it in GitHub Desktop.
How to set up dev enviroment for contributing to Drupal

First of all install DDEV: https://ddev.readthedocs.io/en/stable/#installation

Then execute the following commands:

mkdir drupal9
cd drupal9
ddev config --project-type=drupal9 --docroot=web --create-docroot
ddev start
# You might want to change the default branch depending on the version
# where you want to contribute, you can check the available branches
# here https://www.drupal.org/node/3060/git-instructions/9.3.x/nonmaintainer
git clone --branch '9.3.x' https://git.drupalcode.org/project/drupal.git web

Once having the core downloaded we need to add a few adjustments to the ddev configuration file so let's edit the .ddev/config file and add the following:

# Given that we don't have any file in the drupal9 folder we need to executes
# our commands in the web folder, so the first thing to do is change the working dir
working_dir:
  web: /var/www/html/web
# Now we need to create a link to all our tools that are in the vendor folder
# DDEV add `/var/www/html/bin`  to the $PATH variable, so the easiest is just
# create a symlink to this folder to the vendor folder that is inside the
# web folder, this can be done using a DDEV hook.
hooks:
  post-start:
    - exec: ln -s /var/www/html/web/vendor/bin /var/www/html/bin

After adding the lines, let's restart ddev and then we should be able to use composer and drush

ddev stop && ddev start
ddev . composer install
ddev . composer require drush/drush
ddev . drush si

If drush si ask for credentials, we can execute ddev describe and copy the credentials from there, by default is something like: mysql --host=db --user=db --password=db --database=db

And that's it, once we have drupal installed we can do:

ddev . drush uli
ddev launch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment