{"id":20329351,"url":"https://github.com/ddev/ddev-drupal-contrib","last_synced_at":"2025-04-05T09:06:13.145Z","repository":{"id":158820486,"uuid":"634259708","full_name":"ddev/ddev-drupal-contrib","owner":"ddev","description":"DDEV integration for developing Drupal contrib projects","archived":false,"fork":false,"pushed_at":"2025-03-28T16:02:11.000Z","size":301,"stargazers_count":104,"open_issues_count":5,"forks_count":21,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-03-29T08:05:27.113Z","etag":null,"topics":["ddev-get"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ddev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["ddev"],"custom":["https://www.paypal.com/donate/?hosted_button_id=MCNCSZHC7LHSQ","https://ddev.com/support-ddev/"]}},"created_at":"2023-04-29T14:58:23.000Z","updated_at":"2025-03-12T07:10:37.000Z","dependencies_parsed_at":"2023-05-05T08:24:26.237Z","dependency_job_id":"8eb1a0ea-5432-43a5-8a8b-cc8e8b92734c","html_url":"https://github.com/ddev/ddev-drupal-contrib","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":"ddev/ddev-addon-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddev%2Fddev-drupal-contrib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddev%2Fddev-drupal-contrib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddev%2Fddev-drupal-contrib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddev%2Fddev-drupal-contrib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddev","download_url":"https://codeload.github.com/ddev/ddev-drupal-contrib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312077,"owners_count":20918344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ddev-get"],"created_at":"2024-11-14T20:10:16.650Z","updated_at":"2025-04-05T09:06:13.119Z","avatar_url":"https://github.com/ddev.png","language":"Shell","funding_links":["https://github.com/sponsors/ddev","https://www.paypal.com/donate/?hosted_button_id=MCNCSZHC7LHSQ","https://ddev.com/support-ddev/"],"categories":[],"sub_categories":[],"readme":"[![tests](https://github.com/ddev/ddev-drupal-contrib/actions/workflows/tests.yml/badge.svg)](https://github.com/ddev/ddev-drupal-contrib/actions/workflows/tests.yml) ![project is maintained](https://img.shields.io/maintenance/yes/2025.svg)\n\n# DDEV Drupal Contrib\n\nDDEV 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](https://git.drupalcode.org/project/gitlab_templates) from the Drupal Association.\n\n\n## Install\n\n1. If you haven't already, [install Docker and DDEV](https://ddev.readthedocs.io/en/latest/users/install/)\n2. `git clone` your contrib module\n3. cd [contrib module directory]\n4. Configure DDEV for Drupal using `ddev config --project-type=drupal --docroot=web --php-version=8.3 --corepack-enable --project-name=[module]` or select these options when prompted using `ddev config`\n   - Remove underscores in the project name, or replace with hyphens. (DDEV will do this for you in v1.23.5+)\n   - See [Misc](#misc) for help on using alternate versions of Drupal core.\n5. Run `ddev add-on get ddev/ddev-drupal-contrib` (or `ddev get ddev/ddev-drupal-contrib` if your DDEV version is older than 1.23.5)\n6. Run `ddev start`\n7. Run `ddev poser`\n8. Run `ddev symlink-project`\n9. `ddev config --update` to detect expected Drupal and PHP versions.\n10. `ddev restart`\n\n## Update\n\nFor DDEV v1.23.5 or above run\n\n```sh\nddev add-on get ddev/ddev-drupal-contrib\n```\n\nFor earlier versions of DDEV run\n\n```sh\nddev get ddev/ddev-drupal-contrib\n```\n\n## Commands\n\nThis project provides the following DDEV container commands.\n\n- [ddev poser](https://github.com/ddev/ddev-drupal-contrib/blob/main/commands/web/poser).\n  - Creates a temporary [composer.contrib.json](https://getcomposer.org/doc/03-cli.md#composer) so that `drupal/core-recommended` becomes a dev dependency. This way the composer.json from the module is untouched.\n  - Runs `composer install` AND `yarn install` so that dependencies are available. Additional arguments to `ddev poser` like --prefer-source are passed along to `composer install`\n  - Note: it is perfectly acceptable to skip this command and edit the require-dev of composer.json by hand.\n- [ddev symlink-project](https://github.com/ddev/ddev-drupal-contrib/blob/main/commands/web/symlink-project). 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` _as long as Composer has generated `vendor/autoload.php`_ which occurs during `composer install/update`. See codebase image below.\n\nRun tests on the `web/modules/custom` directory:\n\n- `ddev phpunit` Run [PHPUnit](https://github.com/sebastianbergmann/phpunit) tests.\n- `ddev nightwatch` Run Nightwatch tests, requires [DDEV Selenium Standalone Chrome](https://github.com/ddev/ddev-selenium-standalone-chrome).\n- `ddev phpcs` Run [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer).\n- `ddev phpcbf` Fix phpcs findings.\n- `ddev phpstan`. Run [phpstan](https://phpstan.org) on the web/modules/custom directory.\n- `ddev eslint` Run [ESLint](https://github.com/eslint/eslint) on JavaScript files.\n- `ddev stylelint` Run [Stylelint](https://github.com/stylelint/stylelint) on CSS files.\n\n\n## Codebase layout\n\n![Folder tree](/assets/folders.png)\n\n\n## Misc\n\n- Optional: [Install the ddev-selenium-standalone-chrome extension for FunctionalJavascript and Nightwatch tests](https://github.com/ddev/ddev-selenium-standalone-chrome).\n- Optional: [Install the ddev-mkdocs extension for local preview of your docs site](https://github.com/nireneko/ddev-mkdocs). Drupal.org's Gitlab CI can [automatically publish your site](https://project.pages.drupalcode.org/gitlab_templates/jobs/pages/).\n- Optional. Commit the changes in the `.ddev` folder after this plugin installs. This saves other users from having to install this integration.\n- If you add/remove a root file or directory, re-symlink root files via EITHER of these methods\n  - `ddev restart`\n  - `ddev symlink-project`\n- `cweagans/composer-patches:^1` is added by `ddev poser` so feel free to configure any patches that your project needs.\n- Any development dependencies (e.g. Drush) should be manually added to require-dev in your project's composer.json file. Don't use the `composer require` command to do that.\n\n## Changing defaults\n\nOverride any environment variable value from [.ddev/config.contrib.yaml](config.contrib.yaml) by creating a `.ddev/config.local.yaml` (or [any filename lexicographically following config.contrib.yaml](https://ddev.readthedocs.io/en/stable/users/extend/customization-extendibility/#extending-configyaml-with-custom-configyaml-files)) file which has the same structure as [.ddev/config.contrib.yaml](config.contrib.yaml). Add your overrides under `web_environment`. \n\n### Changing the Drupal core version\n\nIn `.ddev/config.local.yaml` set the Drupal core version:\n```\nweb_environment:\n  - DRUPAL_CORE=^11\n```\n\nThen run `ddev restart` and then `ddev poser` to update the Drupal core version.\n\nIf Drupal core cannot be changed because the project is using an unsupported version of PHP, `ddev poser` will show a `composer` error. In that case, open `.ddev/config.yaml` and change the `PHP_VERSION` to a supported version; then run `ddev restart` and `ddev poser` again.  Note that the project PHP version is set in `.ddev/config.yaml`, while the core version to use is set in `.ddev/config.local.yaml`. \n\n### Changing the symlink location\n\nIn `.ddev/config.local.yaml` set the location relative to webroot (which usually is `web/`). Defaults to `modules/custom`\n```\nweb_environment:\n  - ...\n  - DRUPAL_PROJECTS_PATH=modules\n```\n\nThen restart DDEV by running `ddev restart`.\n\n## Example of successful test\n\nThis is what a successful test looks like, based on [Config Enforce Devel](https://www.drupal.org/project/config_enforce_devel).\n\n```\nuser:~/config_enforce_devel$ ddev phpunit\nPHPUnit 9.6.15 by Sebastian Bergmann and contributors.\n\nDefault Target Module (Drupal\\Tests\\config_enforce_devel\\Functional\\DefaultTargetModule)\n ✔ Default target module created\n\nForm Alter Implementation Order (Drupal\\Tests\\config_enforce_devel\\Functional\\FormAlterImplementationOrder)\n ✔ Form alter implementation order\n\nTheme Settings Form (Drupal\\Tests\\config_enforce_devel\\Functional\\ThemeSettingsForm)\n ✔ Theme settings form submit\n\nTime: 00:13.453, Memory: 4.00 MB\n\nOK (3 tests, 20 assertions)\n```\n\n## Automatically correct coding standard violations\n\nYou can set up a pre-commit hook that runs phpcbf:\n1. Create a new file `touch .git/hooks/pre-commit` in your repository if it doesn't already exist.\n2. Add the following lines to the `pre-commit` file:\n\n```bash\n#!/bin/bash\n\nddev phpcbf -q\n```\n\n3. Mark the file as executable: `chmod +x pre-commit`.\n\n## Add-on tests\n\nTests are done with Bats. It is a testing framework that uses Bash. \n\nTo run tests locally you need to first install bats' git submodules with: \n\n```sh\ngit submodule update --init\n```\n\nThen you can run within the root of this project:\n\n```sh\n./tests/bats/bin/bats ./tests\n```\n\nTests will be run using the default drupal core of the contrib. To test against a different Drupal core version, update the `TEST_DRUPAL_CORE` environment \nvariable.\n\ni.e. `TEST_DRUPAL_CORE=11 ./tests/bats/bin/bats ./tests`.\n\nTests are triggered automatically on every push to the \nrepository, and periodically each night. The automated tests are agains all of\nthe supported Drupal core versions.\n\nPlease make sure to attend to test failures when they happen. Others will be \ndepending on you. \n\nAlso, consider adding tests to test for bugs or new features on your PR.\n\nTo learn more about Bats see the [documentation][bats-docs].\n\n[bats-docs]: https://bats-core.readthedocs.io/en/stable/\n\n## Troubleshooting\n\n\"Error: unknown command\":\n\nThe commands from this addon are available when the project type is `drupal`. Make sure the `type` configuration is correctly set in `.ddev/config.yaml`:\n\n```yaml\ntype: drupal\n```\n\nDon't forget to run `ddev restart` if `.ddev/config.yaml` has been updated.\n\n**Contributed and maintained by [@weitzman](https://github.com/weitzman)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddev%2Fddev-drupal-contrib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddev%2Fddev-drupal-contrib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddev%2Fddev-drupal-contrib/lists"}