Skip to content

DDEV integration for developing Drupal contrib projects

License

Notifications You must be signed in to change notification settings

jonhattan/ddev-drupal-contrib

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tests project is maintained

DDEV Drupal Contrib

DDEV integration for developing Drupal contrib projects. As a general philosophy, your contributed module is the center of the universe. The codebase layout (see image below) and commands in this project match the Gitlab CI approach from the Drupal Association.

Install

  1. If you haven't already, install Docker and DDEV
  2. git clone your contrib module
  3. cd [contrib module directory]
  4. Configure DDEV for Drupal 10 using ddev config --project-name=[contrib module] --project-type=drupal10 --docroot=web --create-docroot --php-version=8.1 or select these options when prompted using ddev config
    • Remove underscores in the project name, or replace with hyphens.
  5. Run ddev get ddev/ddev-drupal-contrib
  6. Run ddev start
  7. Run ddev poser
  8. Run ddev symlink-project

Update

Update by running the ddev get ddev/ddev-drupal-contrib command.

Commands

This project provides the following DDEV container commands.

  • ddev poser.
    • Creates a temporary composer.contrib.json so that drupal/core-recommended becomes a dev dependency. This way the composer.json from the module is untouched.
    • Runs composer install AND yarn install so that dependencies are available.
    • Note: it is perfectly acceptable to skip this command and edit the require-dev of composer.json by hand.
  • ddev symlink-project. This symlinks the top level files of your project into web/modules/custom so that Drupal finds your module. This command runs automatically on every ddev start. See codebase image below.

Run tests on the web/modules/custom directory:

Codebase layout

Folder tree

Misc

Example of succesful test

This is what a succesful test looks like, based on Config Enforce Devel.

user:~/config_enforce_devel$ ddev phpunit
PHPUnit 9.6.15 by Sebastian Bergmann and contributors.

Default Target Module (Drupal\Tests\config_enforce_devel\Functional\DefaultTargetModule)
 ✔ Default target module created

Form Alter Implementation Order (Drupal\Tests\config_enforce_devel\Functional\FormAlterImplementationOrder)
 ✔ Form alter implementation order

Theme Settings Form (Drupal\Tests\config_enforce_devel\Functional\ThemeSettingsForm)
 ✔ Theme settings form submit

Time: 00:13.453, Memory: 4.00 MB

OK (3 tests, 20 assertions)

Troubleshooting

"Error: unknown command":

The commands from this addon are available when the project type a valid drupal type. Below, is an example .ddev/config.yaml for a Drupal 10 project.

type: drupal10

Contributed and maintained by @weitzman

About

DDEV integration for developing Drupal contrib projects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%