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