From 3ac626f3f9a262a28d0008c359bf052ae9f1f31d Mon Sep 17 00:00:00 2001 From: Sampo Turve Date: Tue, 13 Aug 2024 10:48:24 +0300 Subject: [PATCH] GH-420: Initial DDEV support --- .ddev/commands/web/grumphp-command.sh | 7 +++++++ .ddev/config.yaml | 24 ++++++++++++++++++++++++ .lando.yml | 5 +++-- grumphp.yml | 2 +- web/sites/default/settings.php | 11 +++++++++++ 5 files changed, 46 insertions(+), 3 deletions(-) create mode 100755 .ddev/commands/web/grumphp-command.sh create mode 100644 .ddev/config.yaml diff --git a/.ddev/commands/web/grumphp-command.sh b/.ddev/commands/web/grumphp-command.sh new file mode 100755 index 0000000..1e1f4df --- /dev/null +++ b/.ddev/commands/web/grumphp-command.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +## Description: Run a GrumPHP command. +## Usage: grumphp +## Example: "ddev grumphp" + +php /var/www/html/vendor/bin/grumphp "$@" diff --git a/.ddev/config.yaml b/.ddev/config.yaml new file mode 100644 index 0000000..024c8a2 --- /dev/null +++ b/.ddev/config.yaml @@ -0,0 +1,24 @@ +name: drupal-project +type: drupal +docroot: web +php_version: "8.2" +webserver_type: nginx-fpm +xdebug_enabled: true +additional_hostnames: [] +additional_fqdns: [] +database: + type: mariadb + version: "10.11" +use_dns_when_possible: true +composer_version: "2" +disable_settings_management: true +web_environment: + - DB_NAME=db + - DB_USER=db + - DB_PASS=db + - DB_HOST=db + - DRUSH_OPTIONS_URI=https://drupal-project.ddev.site + - ENVIRONMENT_NAME=ddev + - EXEC_GRUMPHP_COMMAND=ddev php + - HASH_SALT=notsosecurehash +corepack_enable: false diff --git a/.lando.yml b/.lando.yml index f114712..7f6728b 100644 --- a/.lando.yml +++ b/.lando.yml @@ -70,9 +70,10 @@ services: environment: # Database credentials are defined in the .lando/.env file # to be available in both the adminer and appserver containers. - HASH_SALT: notsosecurehash - ENVIRONMENT_NAME: lando DRUSH_OPTIONS_URI: https://drupal-project.lndo.site + ENVIRONMENT_NAME: lando + EXEC_GRUMPHP_COMMAND: "lando php" + HASH_SALT: notsosecurehash VARNISH_ADMIN_HOST: varnish # Support debugging with XDEBUG 3. XDEBUG_MODE: diff --git a/grumphp.yml b/grumphp.yml index e906ab1..5433c9a 100644 --- a/grumphp.yml +++ b/grumphp.yml @@ -40,4 +40,4 @@ grumphp: - Wunderio\GrumPHP\Task\YamlLint\YamlLintExtensionLoader - Wunderio\GrumPHP\Task\JsonLint\JsonLintExtensionLoader git_hook_variables: - EXEC_GRUMPHP_COMMAND: lando php + EXEC_GRUMPHP_COMMAND: ${EXEC_GRUMPHP_COMMAND} diff --git a/web/sites/default/settings.php b/web/sites/default/settings.php index 7909e1f..955d6eb 100644 --- a/web/sites/default/settings.php +++ b/web/sites/default/settings.php @@ -55,6 +55,7 @@ $settings['simple_environment_indicator'] = 'DarkBlue Stage'; break; + case 'ddev': case 'local': case 'lando': $settings['simple_environment_indicator'] = 'DarkGreen Local'; @@ -72,6 +73,16 @@ $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null'; $settings['cache']['bins']['page'] = 'cache.backend.null'; $settings['extension_discovery_scan_tests'] = FALSE; + + // Override drupal/symfony_mailer default config to use Mailpit. + if ($env === 'ddev') { + $config['symfony_mailer.settings']['default_transport'] = 'sendmail'; + $config['symfony_mailer.mailer_transport.sendmail']['plugin'] = 'smtp'; + $config['symfony_mailer.mailer_transport.sendmail']['configuration']['user'] = ''; + $config['symfony_mailer.mailer_transport.sendmail']['configuration']['pass'] = ''; + $config['symfony_mailer.mailer_transport.sendmail']['configuration']['host'] = 'localhost'; + $config['symfony_mailer.mailer_transport.sendmail']['configuration']['port'] = '1025'; + } break; default: