Skip to content

Commit

Permalink
Merge pull request #27 from acquia/ACMS-3478
Browse files Browse the repository at this point in the history
ACMS-3478: Update README.md file.
  • Loading branch information
vishalkhode1 authored Jan 17, 2024
2 parents dd0bcf8 + 01b51ac commit 5c06103
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 16 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,23 @@ It allows your websites to be easily installed in both Acquia Cloud IDE & local
and deployable on Acquia Cloud.

## Installation
### Install using Composer

### Include Acquia Global Command in DRS for multisite functionality
To use global command with DRS for multisite functionality please add below in
your root composer.json file.
```
"repositories": {
"acquia_global_commands": {
"type": "vcs",
"url": "git@github.com:vishalkhode1/acquia_global_commands.git"
}
}
composer require acquia/drupal-recommended-settings
```

You can also install this using Composer like so:

### Multi-site features with Acquia DRS
The Drupal Recommended Settings offer the multi-site feature out of the box.
To configure a multi-site, run the following command, and the plugin will
automatically generate the settings.php in the backend.
```
composer require acquia/drupal-recommended-settings
drush site:install --uri site1
```

The plugin offers various events that allow you to implement custom logic based
on when these events are triggered. You can find the examples of such
implementations from [here](examples).

# Quick examples
## Generate settings for a given site
```
Expand All @@ -51,7 +49,8 @@ $settings = new Settings(DRUPAL_ROOT, $siteUri);
try {
// Call generate method.
$settings->generate();
} catch (SettingsException $e) {
}
catch (SettingsException $e) {
echo $e->getMessage();
}
```
Expand All @@ -77,7 +76,7 @@ $settings = new Settings(DRUPAL_ROOT, $siteUri);
$dbSpec = [
'drupal' => [
'db' => [
'database' => 'drupal',
'database' => 'drupal', // In case of multi-site database name is replaced with the site name.
'username' => 'drupal',
'password' => 'drupal',
'host' => 'localhost',
Expand All @@ -89,7 +88,8 @@ $dbSpec = [
try {
// Call generate method passing database details.
$settings->generate($dbSpec);
} catch (SettingsException $e) {
}
catch (SettingsException $e) {
echo $e->getMessage();
}
```
Expand Down
2 changes: 2 additions & 0 deletions examples/example-drush-command/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## About
Provides an example implemention of events provided by DRS.
22 changes: 22 additions & 0 deletions examples/example-drush-command/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "example/example-drush-command",
"description": "Example custom drush commands.",
"keywords": [
"drush",
"drupal"
],
"license": "GPL-2.0-or-later",
"require": {
"acquia/drupal-recommended-settings": "*"
},
"autoload": {
"psr-4": {
"Example\\": "src"
}
},
"config": {
"allow-plugins": {
"acquia/drupal-recommended-settings": true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Example\Drush\Commands;

use Acquia\Drupal\RecommendedSettings\Drush\Commands\MultisiteDrushCommands;
use Consolidation\AnnotatedCommand\CommandData;
use Consolidation\AnnotatedCommand\Hooks\HookManager;
use Drush\Attributes as CLI;
use Drush\Commands\DrushCommands;

/**
* An example drush command file.
*/
class ExampleDrushCommands extends DrushCommands {

/**
* Do not generate settings.php file to site1.
*/
#[CLI\Hook(type: HookManager::ON_EVENT, target: MultisiteDrushCommands::VALIDATE_GENERATE_SETTINGS)]
public function skipQuestionForSite(CommandData $commandData): bool {
// DO NOT ask question for site: `site1`.
if ($commandData->input()->getOption("uri") == "site1") {
return FALSE;
}
return TRUE;
}

/**
* Display successful message, after settings files are generated/updated.
*/
#[CLI\Hook(type: HookManager::ON_EVENT, target: MultisiteDrushCommands::POST_GENERATE_SETTINGS)]
public function showSuccessMessage(CommandData $commandData): void {
$uri = $commandData->input()->getOption("uri");
$this->io()->info("The settings.php generated successfully for site `" . $uri . "`.");
}

}

0 comments on commit 5c06103

Please sign in to comment.