|
1 | 1 | # Acquia Drupal Recommended Settings
|
2 |
| -The Acquia Drupal Recommended Settings plugin adds the recommended settings to the Drupal project, so developers won't have to edit settings.php manually. |
| 2 | +The Acquia Drupal Recommended Settings plugin adds the recommended settings to |
| 3 | +the Drupal project, so developers won't have to edit settings.php manually. |
3 | 4 |
|
4 | 5 | The recommended settings includes:
|
5 |
| -- the required database credentials |
6 |
| -- configuration sync directory path. |
7 |
| -- public/private etc. file directory path. |
| 6 | +- The required database credentials. |
| 7 | +- Configuration sync directory path. |
| 8 | +- File directory path i.e public/private etc. |
8 | 9 | - Acquia site studio sync directory path.
|
9 |
| -- Includes Drupal module [Config sync without site uuid](https://www.drupal.org/project/config_sync_without_site_uuid) features. |
10 | 10 |
|
11 |
| -It allows your websites to be easily installed in both Acquia Cloud IDE & local and deployable on Acquia Cloud. |
| 11 | +It allows your websites to be easily installed in both Acquia Cloud IDE & local |
| 12 | +and deployable on Acquia Cloud. |
12 | 13 |
|
13 | 14 | ## Installation
|
14 |
| - |
15 |
| -You can also install this using Composer like so: |
| 15 | +### Install using Composer |
16 | 16 |
|
17 | 17 | ```
|
18 | 18 | composer require acquia/drupal-recommended-settings
|
19 | 19 | ```
|
20 |
| - |
21 |
| -## Steps to switch from BLT to Acquia Drupal Recommended Settings |
22 |
| -This plugin doesn't work with the acquia/blt plugin. If the plugin exists, it must be removed. |
23 |
| - |
24 |
| -- Remove BLT plugin using below command |
| 20 | +### Multi-site features with Acquia DRS |
| 21 | +The Drupal Recommended Settings offer the multi-site feature out of the box. |
| 22 | +To configure a multi-site, run the following command, and the plugin will |
| 23 | +automatically generate the settings.php in the backend. |
25 | 24 | ```
|
26 |
| -composer remove acquia/blt |
| 25 | +drush site:install --uri site1 |
27 | 26 | ```
|
28 | 27 |
|
29 |
| -- Remove BLT reference from settings.php file located at |
30 |
| -``/docroot/sites/default/settings.php``. |
31 |
| -```php |
32 |
| -require DRUPAL_ROOT . "/../vendor/acquia/blt/settings/blt.settings.php"; |
| 28 | +The plugin offers various events that allow you to implement custom logic based |
| 29 | +on when these events are triggered. You can find the examples of such |
| 30 | +implementations from [here](examples). |
| 31 | + |
| 32 | +# Quick examples |
| 33 | +## Generate settings for a given site |
| 34 | + ``` |
| 35 | +<?php |
| 36 | +
|
33 | 37 | /**
|
34 |
| - * IMPORTANT. |
35 |
| - * |
36 |
| - * Do not include additional settings here. Instead, add them to settings |
37 |
| - * included by `blt.settings.php`. See BLT's documentation for more detail. |
38 |
| - * |
39 |
| - * @link https://docs.acquia.com/blt/ |
| 38 | + * @file |
| 39 | + * Include DRS settings. |
40 | 40 | */
|
41 |
| -``` |
42 | 41 |
|
43 |
| -- Require Acquia Drupal Recommended Settings plugin using |
| 42 | +use Acquia\Drupal\RecommendedSettings\Exceptions\SettingsException; |
| 43 | +use Acquia\Drupal\RecommendedSettings\Settings; |
| 44 | +
|
| 45 | +// Create settings object. |
| 46 | +$siteUri = "site1"; |
| 47 | +$settings = new Settings(DRUPAL_ROOT, $siteUri); |
| 48 | +
|
| 49 | +try { |
| 50 | + // Call generate method. |
| 51 | + $settings->generate(); |
| 52 | +} |
| 53 | +catch (SettingsException $e) { |
| 54 | + echo $e->getMessage(); |
| 55 | +} |
44 | 56 | ```
|
45 |
| -composer require acquia/drupal-recommended-settings |
| 57 | + |
| 58 | +## Generate settings for a given site passing database credentials |
| 59 | + |
46 | 60 | ```
|
47 |
| - |
48 |
| -- Update `default.local.settings.php` and `local.settings.php` to use the Environment Detector provided by this plugin instead of BLT: |
49 |
| -```diff |
50 |
| -- use Acquia\Blt\Robo\Common\EnvironmentDetector; |
51 |
| -+ use Acquia\Drupal\RecommendedSettings\Helpers\EnvironmentDetector; |
| 61 | +<?php |
| 62 | +
|
| 63 | +/** |
| 64 | + * @file |
| 65 | + * Include DRS settings. |
| 66 | + */ |
| 67 | +
|
| 68 | +use Acquia\Drupal\RecommendedSettings\Exceptions\SettingsException; |
| 69 | +use Acquia\Drupal\RecommendedSettings\Settings; |
| 70 | +
|
| 71 | +// Create settings object. |
| 72 | +$siteUri = "site1"; |
| 73 | +$settings = new Settings(DRUPAL_ROOT, $siteUri); |
| 74 | +
|
| 75 | +// Database details. |
| 76 | +$dbSpec = [ |
| 77 | + 'drupal' => [ |
| 78 | + 'db' => [ |
| 79 | + 'database' => 'drupal', // In case of multi-site database name is replaced with the site name. |
| 80 | + 'username' => 'drupal', |
| 81 | + 'password' => 'drupal', |
| 82 | + 'host' => 'localhost', |
| 83 | + 'port' => '3306', |
| 84 | + ], |
| 85 | + ], |
| 86 | +]; |
| 87 | +
|
| 88 | +try { |
| 89 | + // Call generate method passing database details. |
| 90 | + $settings->generate($dbSpec); |
| 91 | +} |
| 92 | +catch (SettingsException $e) { |
| 93 | + echo $e->getMessage(); |
| 94 | +} |
52 | 95 | ```
|
53 | 96 |
|
54 | 97 | # License
|
55 | 98 |
|
56 | 99 | Copyright (C) 2023 Acquia, Inc.
|
57 | 100 |
|
58 |
| -This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. |
| 101 | +This program is free software: you can redistribute it and/or modify it under |
| 102 | +the terms of the GNU General Public License version 2 as published by the |
| 103 | +Free Software Foundation. |
59 | 104 |
|
60 |
| -This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 105 | +This program is distributed in the hope that it will be useful, |
| 106 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 107 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 108 | +See the GNU General Public License for more details. |
0 commit comments