Requires at least PHPStorm 2022.2 because of this issue: https://youtrack.jetbrains.com/issue/WI-62463
This is my personal development environment when working with Drupal. Created via the
composer create-project drupal/recommended-project my_site_name_dir command, see the drupal docs
for more info: https://www.drupal.org/node/2718229?no_cache=1651100340#s-create-a-project.
The drupal/core-dev package is included which brings phpcs, and PHPUnit into the project. phpstan-drupal is also included.
This repository is also some kind of resource collection for my self to quickly set up a development environment.
This setup uses ddev to provide a webserver and database via docker compose.
To start the containers, run: ddev start
Stop: ddev stop
Import database dump: ddev import-db --src=/path/to/db.sql.gz
Use ddev describe to get detailed info about the services:
To get a list of all available commands, use ddev -h
For more see the ddev CLI Docs.
Prefix all composer commands with ddev, eg. ddev composer install.
Prefix all drush commands with ddev, eg. ddev drush cr.
Configurations for PHPStorm are included. There is also a post-composer hook to automatically create a basic phpunit.xml config file:
hooks:
post-composer:
- exec: ./.ddev/scripts/phpunit-config.sh
Drupal's configs are stored at /config.
The configs include a basic installation with the standard profile.
This is the complete hooks section from the ddev config.yaml:
hooks:
post-composer:
# Create and configure PHPUnit config file
- exec: ./.ddev/scripts/phpunit-config.sh
post-start:
# Install Drupal after start if not installed already
- exec: "(drush status bootstrap | grep -q Successful) || echo '$settings[\'config_sync_directory\'] = \'./../config\';' >> web/sites/default/settings.php && drush site-install -y --db-url=mysql://db:db@db/db"
# Generate a one-time login link for the admin account.
- exec: "drush uli 1"
Besides the PHPUnit configuration (post-composer), there are also some kind of one-time installation routine living in
post-start section. This will check (every time you start the project) if Drupal is installed. If so, a one time login
link for user 1 is printed to the console via drush. If Drupal ist not already installed, it gets installed via
drush site install using the Drupal configs in /config.
Includes necessary PHPStorm configs for:
- PHP CodeSniffer
- PHPStan Drupal
- PHP Interpreter via ddev (docker-compose)
- [Drupal.org] CodeSniffer
- [ddev Docs] PhpStorm Integration
- [ddev Docs] ddev Hooks
- [ddev Docs] ddev Commands
- [ddev Docs] ddev Custom services
- [Blocker] PHPStorm Bug
- [GitHub] drupal/core-dev
- [mglaman.dev] PHPStan
- [mglaman.dev] Running Drupal's PHPUnit test suites on DDEV
- [mglaman.dev] Running Drupal's FunctionalJavascript tests on DDEV
- [mglaman.dev] Running Drupal's Nightwatch test suite on DDEV
- [Drupal.org] PHPUnit in Drupal
- [Drupal.org] Running PHPUnit tests
- [drush.org] Drush commands
ddev composer require 'drupal/core-recommended:^10' 'drupal/core-composer-scaffold:^10' 'drupal/core-project-message:^10' --update-with-dependencies --no-update
ddev composer require 'drupal/core-dev:^10' --dev --update-with-dependencies --no-update
ddev composer update
Thanks to Matt Glaman for the webdriver container (https://mglaman.dev/blog/running-drupals-functionaljavascript-tests-ddev).
