Skip to content

Commit 88180ab

Browse files
committed
QAG-31: (docs) Improve README.md formatting and readability
- Consolidate duplicate commands across environments Refs: README.md
1 parent 776d8be commit 88180ab

File tree

1 file changed

+112
-48
lines changed

1 file changed

+112
-48
lines changed

README.md

Lines changed: 112 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This project is a tailored fork of the popular [drupal-composer template](https:
55
## Getting started
66

77
1. **Create a new project repository**
8-
Click "[Use this template](https://github.com/wunderio/drupal-project/generate)" to generate a new project:
8+
Click "[Use this template](https://github.com/wunderio/drupal-project/generate)" to generate a new project:
99
- Select the correct owner.
1010
- Name the project as `client-COUNTRYCODE-CLIENT-PROJECT`.
1111
- Set the repository to private (unless the project is public).
@@ -77,20 +77,22 @@ This project supports two local development environments: DDEV (preferred) and L
7777
2. Ensure Docker is running on your system
7878
3. Start the environment and set up your project:
7979

80-
```bash
81-
# Start the DDEV environment
82-
ddev start
80+
```bash
81+
# Start the DDEV environment
82+
ddev start
8383

84-
# Authenticate SSH for database syncing
85-
ddev auth ssh
84+
# Authenticate SSH for database syncing
85+
ddev auth ssh
8686

87-
# Synchronize local database with a remote environment
88-
# See `scripts/syncdb.sh` for options
89-
ddev syncdb
87+
# Synchronize local database with a remote environment
88+
# See `scripts/syncdb.sh` for options
89+
ddev syncdb
9090

91-
# Get a one-time login link for admin access
92-
ddev drush uli
93-
```
91+
# Get a one-time login link for admin access
92+
drush uli
93+
```
94+
95+
Note: All commands in the DDEV section should be run within the DDEV environment using `ddev` prefix (e.g., `ddev drush uli`), or by using `ddev ssh` to access the container shell first.
9496

9597
#### DDEV services and access points
9698

@@ -141,9 +143,9 @@ For a complete list of all available services, URLs, and ports, use:
141143
1. Install [Lando](https://github.com/lando/lando/releases)
142144
2. Start the environment:
143145

144-
```bash
145-
lando start
146-
```
146+
```bash
147+
lando start
148+
```
147149

148150
#### Lando common commands
149151

@@ -194,44 +196,106 @@ This project uses [Cursor](https://docs.cursor.com/) as the recommended AI-power
194196

195197
### Varnish and Purge configuration
196198

197-
1. **Enable Varnish:**
198-
- Uncomment the Varnish configuration in `.lando.yml` under `services → varnish` and `proxy → varnish`.
199-
- Run `lando rebuild -y`.
199+
This section describes how to set up Varnish caching and Purge functionality in your local development environment.
200+
201+
Note: Drush commands in this section should be run with the appropriate environment prefix (`ddev` or `lando`).
202+
203+
#### Configuration Overview
204+
205+
The project includes ready-to-use Varnish configuration:
206+
207+
1. **Configuration Import (Recommended)**
208+
- For existing projects, simply import the configuration from `config/sync`:
209+
210+
```bash
211+
drush cim -y
212+
```
213+
214+
- This applies all Purge and Varnish settings, including processors and purgers
215+
216+
2. **Manual Configuration (for new sites)**
217+
- If config/sync is not available, follow these steps:
218+
219+
a. **Install required modules**:
220+
221+
```bash
222+
drush en purge purge_drush purge_processor_lateruntime purge_queuer_coretags purge_tokens purge_ui varnish_purger varnish_purge_tags -y
223+
```
224+
225+
b. **Configure Varnish Purger**:
226+
- Set a value for **Browser and proxy cache maximum age** in `admin/config/development/performance`
227+
- Navigate to `/admin/config/development/performance/purge`
228+
- Click **Add purger** and select **Varnish Purger**:
229+
- **Name:** "Varnish Purger"
230+
- **Type:** "Tags"
231+
- **Request method:** "BAN" (important: use BAN instead of PURGE for compatibility with Silta)
232+
- **Headers:** `Cache-Tags`: `[invalidation:expression]`
233+
- Save the configuration
200234

201-
2. **Basic installation profile configuration:**
202-
- Install the `basic` profile: `lando drush si basic -y`.
203-
- This sets up Purge and Varnish Purge out of the box.
235+
c. **Configure processors**:
236+
- Go to `/admin/config/development/performance/purge/processors`
237+
- Ensure these processors are enabled:
238+
- `drush_purge_invalidate` (for manual invalidation via Drush)
239+
- `lateruntime` (for batching invalidations)
240+
- `purge_ui_block_processor` (for admin UI functionality)
204241

205-
3. **Configuration for installed sites:**
206-
- Enable the required modules:
242+
d. **Export the configuration**:
207243

208-
```bash
209-
lando drush en purge purge_drush purge_processor_lateruntime purge_queuer_coretags purge_tokens purge_ui varnish_purger varnish_purge_tags -y
210-
```
244+
```bash
245+
drush cex -y
246+
```
211247

212-
- Set a value for **Browser and proxy cache maximum age** in `admin/config/development/performance`.
213-
- Navigate to `/admin/config/development/performance/purge`, click **Add purger**, and select **Varnish Purger**:
214-
- **Name:** "Varnish Purger"
215-
- **Headers:** `Cache-Tags`: `[invalidation:expression]`
216-
- Save the configuration.
217-
- Export the configuration:
248+
e. **Update settings.php**:
249+
- Find the purger ID in `varnish_purger.settings.<PURGER_ID>.yml`
250+
- Update `web/sites/default/settings.php` with the correct purger ID:
218251

219-
```bash
220-
lando drush cex -y
221-
```
252+
```php
253+
if (getenv('VARNISH_ADMIN_HOST')) {
254+
$config['varnish_purger.settings.<PURGER_ID>']['hostname'] = trim(getenv('VARNISH_ADMIN_HOST'));
255+
$config['varnish_purger.settings.<PURGER_ID>']['port'] = getenv('VARNISH_ADMIN_PORT') ? trim(getenv('VARNISH_ADMIN_PORT')) : '80';
256+
}
257+
```
258+
259+
#### Environment-Specific Setup
260+
261+
##### DDEV (Recommended)
262+
263+
1. **Varnish Configuration**: DDEV comes pre-configured with Varnish in `.ddev` folder.
264+
265+
2. **Testing Configuration**:
266+
267+
```bash
268+
ddev drush cr
269+
ddev exec curl -X BAN -H "Cache-Tags: config:system.performance" http://varnish
270+
```
271+
272+
If working correctly, you should receive a "200 Ban added" response
273+
274+
3. **Viewing Varnish logs**:
275+
276+
```bash
277+
ddev exec -s varnish varnishlog -i BAN -i Cache
278+
```
279+
280+
##### Lando
281+
282+
1. **Enable Varnish**:
283+
- Varnish configuration is already enabled in `.lando.yml` & `.lando/varnish.vcl`.
284+
285+
2. **Testing Configuration**:
286+
287+
```bash
288+
lando drush cr
289+
lando ssh -c "curl -X BAN -H 'Cache-Tags: config:system.performance' http://varnish"
290+
```
222291
223-
- Find the purger ID in the exported `varnish_purger.settings.<PURGER_ID>.yml` file.
224-
- Update `web/sites/default/settings.php`:
225-
- Replace all occurrences of `varnish_purger.settings.<OLD_ID>` with the new purger ID.
226-
- Clear the cache:
292+
### Important Notes
227293
228-
```bash
229-
lando drush cr
230-
```
294+
- **BAN vs PURGE Method:** Always use the "BAN" method in the Varnish purger configuration instead of "PURGE". The Silta Varnish configuration is set up to handle BAN requests but may reject PURGE requests with "405 Method Not Allowed" errors.
231295
232-
Varnish should now be configured to handle caching and purging when content is updated.
296+
- **Processors:** The default Purge setup uses the `purge_processor_lateruntime` module, which empties the purge queue during page requests. This works well for most sites needing immediate cache clearing. Ensure all required processors are enabled.
233297
234-
**Note:** The default Purge setup uses the `purge_processor_lateruntime` module, which empties the purge queue during page requests. This works well for most sites needing immediate cache clearing.
298+
- **Cache Tags:** The Varnish configuration is set up to handle cache tag invalidation with the `Cache-Tags` header.
235299
</details>
236300
237301
<details>
@@ -243,11 +307,11 @@ The [PHPUnit](https://phpunit.de/) test framework is predefined in this project.
243307
244308
#### Testing examples
245309
246-
Use `lando phpunit` to run PHPUnit commands:
310+
Note: Run these commands with the appropriate environment prefix (`ddev phpunit` or `lando phpunit`).
247311
248-
- Run one test class: `lando phpunit path/to/your/class/file.php`
249-
- List groups: `lando phpunit --list-groups`
250-
- Run all tests in a particular group: `lando phpunit --group Groupname`
312+
- Run one test class: `phpunit path/to/your/class/file.php`
313+
- List groups: `phpunit --list-groups`
314+
- Run all tests in a particular group: `phpunit --group Groupname`
251315
</details>
252316
253317
### Secrets handling

0 commit comments

Comments
 (0)