Creating a development environment for Drupal is tedious. This project is an attempt to make it a bit easier.
- Docker4Drupal as a foundation with a small adjustments. All documentation from D4D is applicable for this project.
- drupalrc for simplified interaction with Drupal related tools from the CLI.
Tip
This workflow is intended to be used for each contrib module separately. This means all these steps should be repeated for each individual contrib module.
- Clone this repository:
git clone git@github.com:Niklan/Docker4DrupalContrib.git DRUPAL_PROJECT_NAME
- Adjust
.env
file: drupal core version, project name, PHP version etc. - Clone contrib module into
/project
:git clone git@git.drupal.org:project/DRUPAL_PROJECT_NAME.git project
- Run the containers and enjoy!
docker compose up -d
git clone git@github.com:Niklan/Docker4DrupalContrib.git pathauto
cd pathauto
git clone git@git.drupal.org:project/pathauto.git project
# Note: this will also affects 'DRUPAL_PROJECT_NAME' which is expected.
sed -i 's/PROJECT_NAME=/PROJECT_NAME=pathauto/g' .env
docker compose up -d
docker compose exec php bash
# Navigate into module dir.
dcd pathauto
# Run PHPCS
drupalcs .
# Run PHPUnit
dunit .
docker compose down -v
docker compose build --no-cache
docker compose up -d
- Enter to
php
container shell:
docker compose exec php bash
- Run:
build-composer-json
This is where drupalrc will come to rescue.
First, you have to enter into shell (note that it should bash
, not sh
):
docker compose exec php bash
Then you can use drupalrc:
- Navigate to module sources (you can type it manually instead of using env):
dcd $DRUPAL_PROJECT_NAME
- PHPCS
drupalcs .
- PHPUnit
dunit .