Skip to content

Commit 217d9c6

Browse files
authored
[docs] Add Drupal Multisite recommendations (ddev#4600) [skip ci]
1 parent c10eea1 commit 217d9c6

File tree

1 file changed

+58
-5
lines changed

1 file changed

+58
-5
lines changed

docs/content/users/usage/cms-settings.md

+58-5
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,69 @@ This environment variable is set `true` by default in DDEV’s environment, and
3636

3737
### Drupal Specifics
3838

39-
* **Settings Files**: By default, DDEV will create settings files for your project that make it “just work” out of the box. It creates a `sites/default/settings.ddev.php` and adds an include in `sites/default/settings.php` to bring that in. There are guards to prevent the `settings.ddev.php` from being active when the project is not running under DDEV, but it still should not be checked in and is gitignored.
40-
* **Database requirements for Drupal 9.5+ +**:
41-
* Using MySQL or MariaDB, Drupal requires `SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED` and DDEV does this for you on [`ddev start`](../usage/commands.md#start).
42-
* Using PostgreSQL, Drupal requires the`pg_trm` extension. DDEV creates this extension automatically for you on `ddev start`.
43-
* **Twig Debugging**: With the default Drupal configuration, it’s very difficult to debug Twig templates; you need to use `development.services.yml` instead of `services.yml`. Add this line in your `settings.php` or `settings.local.php`. See discussion at [drupal.org](https://www.drupal.org/forum/support/module-development-and-code-questions/2019-09-02/ddev-twig-debugging) and the Drupal documentation.
39+
#### Drupal Settings Files
40+
41+
By default, DDEV will create settings files for your project that make it “just work” out of the box. It creates a `sites/default/settings.ddev.php` and adds an include in `sites/default/settings.php` to bring that in. There are guards to prevent the `settings.ddev.php` from being active when the project is not running under DDEV, but it still should not be checked in and is gitignored.
42+
43+
#### Database requirements for Drupal 9.5+
44+
45+
* Using MySQL or MariaDB, Drupal requires `SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED` and DDEV does this for you on [`ddev start`](../usage/commands.md#start).
46+
* Using PostgreSQL, Drupal requires the`pg_trm` extension. DDEV creates this extension automatically for you on `ddev start`.
47+
48+
#### Twig Debugging
49+
50+
With the default Drupal configuration, it’s very difficult to debug Twig templates; you need to use `development.services.yml` instead of `services.yml`. Add this line in your `settings.php` or `settings.local.php`. See discussion at [drupal.org](https://www.drupal.org/forum/support/module-development-and-code-questions/2019-09-02/ddev-twig-debugging) and the Drupal documentation.
4451

4552
```php
4653
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';
4754
```
4855

56+
#### Multisite
57+
58+
1. Start with the [DDEV Drupal 8 Multisite Recipe](<https://github.com/drud/ddev-contrib/tree/master/recipes/drupal8-multisite>).
59+
2. Update configuration files.
60+
1. Update each `site/{site_name}/settings.php`:
61+
62+
```php
63+
/**
64+
* DDEV environments will have $databases (and other settings) set
65+
* by an auto-generated file. Make alterations here for this site
66+
* in a multisite environment.
67+
*/
68+
elseif (getenv('IS_DDEV_PROJECT') == 'true') {
69+
/**
70+
* Alter database settings and credentials for DDEV environment.
71+
* Includes loading the DDEV-generated `default/settings.ddev.php`.
72+
*/
73+
include $app_root . '/' . $site_path . '/settings.databases.ddev.inc';
74+
}
75+
```
76+
77+
2. Add a `settings.databases.ddev.inc` in each `site/{site_name}/`:
78+
79+
```php
80+
/**
81+
* Fetch DDEV-generated database credentials and other settings.
82+
*/
83+
require $app_root . '/sites/default/settings.ddev.php';
84+
85+
/*
86+
* Alter default database for this site. `settings.ddev.php` will have
87+
* “reset” this to 'db'.
88+
*/
89+
$databases['default']['default']['database'] = 'site_name';
90+
```
91+
92+
3. Update your [`web_environment`](../configuration/config.md#web_environment) config option if you’re using site aliases:
93+
94+
```yaml
95+
web_environment:
96+
# Make DDEV Drush shell PIDs last for entire life of the container
97+
# so `ddev drush site:set @alias` persists for all Drush connections.
98+
# https://chrisfromredfin.dev/posts/drush-use-ddev/
99+
- DRUSH_SHELL_PID=PERMANENT
100+
```
101+
49102
### TYPO3 Specifics
50103

51104
#### Settings Files

0 commit comments

Comments
 (0)