@bostonuniversity/buwp-local 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,466 @@
1
+ # Volume Mapping Patterns
2
+
3
+ Guide to configuring volume mappings for different development workflows in buwp-local.
4
+
5
+ ## Overview
6
+
7
+ Volume mappings connect your local filesystem to the WordPress container, enabling live code sync and IDE integration. There are two main approaches based on **where buwp-local lives**:
8
+
9
+ - **Inside your plugin/theme repo** (Pattern A) - Self-contained, like wp-env
10
+ - **In a separate "base camp" directory** (Patterns B & C) - Coordinates multiple repos
11
+
12
+ This guide documents three patterns based on real user workflows.
13
+
14
+ **Quick Navigation:**
15
+ - [Pattern A: In-Repo Development](#pattern-a-in-repo-development) - Single plugin/theme, wp-env style
16
+ - [Pattern B: Sandbox Coordination](#pattern-b-sandbox-coordination) - Multiple repos from base camp
17
+ - [Pattern C: Monolithic Sandbox](#pattern-c-monolithic-sandbox) - Full WordPress build in base camp
18
+ - [Choosing a Pattern](#choosing-a-pattern) - Decision guide
19
+
20
+ ---
21
+
22
+ ## Pattern A: In-Repo Development
23
+
24
+ **Use Case:** Single plugin or theme development, wp-env style
25
+
26
+ ### Description
27
+
28
+ buwp-local is installed directly in your plugin or theme repository. It can be configured by `npx buwp-local init`, which will try to detect if is being run within a plugin or theme directory and automatically set up the volume mapping. The repository is self-contained and maps itself into WordPress.
29
+
30
+ **Good for:**
31
+ - Transitioning from wp-env
32
+ - Open source plugins (distributable setup)
33
+ - Single-focus development
34
+ - Projects where repo includes dev environment setup
35
+
36
+ ### Pros & Cons
37
+
38
+ **Pros:**
39
+ - ✅ Simplest setup (`init` can auto-configure)
40
+ - ✅ Self-contained to one repo (each repo can have its own setup)
41
+ - ✅ Fast volume performance (minimal mapping)
42
+ - ✅ Clean isolation (your code vs WordPress core)
43
+ - ✅ Familiar to wp-env users
44
+
45
+ **Cons:**
46
+ - ❌ Can't easily develop multiple plugins together
47
+ - ❌ Local sites don't share content or database
48
+ - ❌ No IDE context for WordPress core
49
+
50
+ ### Example Configuration
51
+
52
+ **Directory Structure:**
53
+ ```
54
+ ~/projects/bu-custom-analytics/ ← Your plugin repo
55
+ ├── .buwp-local.json ← buwp-local config
56
+ ├── package.json ← Has buwp-local as devDependency
57
+ ├── node_modules/
58
+ │ └── @bostonuniversity/buwp-local/
59
+ ├── bu-custom-analytics.php
60
+ ├── includes/
61
+ └── assets/
62
+
63
+ Container:
64
+ /var/www/html/ (Docker volume)
65
+ └── wp-content/
66
+ └── plugins/
67
+ └── bu-custom-analytics/ (→ mapped to your repo root)
68
+ ```
69
+
70
+ **Configuration File (`.buwp-local.json`):**
71
+ ```json
72
+ {
73
+ "projectName": "bu-custom-analytics",
74
+ "hostname": "bu-custom-analytics.local",
75
+ "mappings": [
76
+ {
77
+ "local": "./",
78
+ "container": "/var/www/html/wp-content/plugins/bu-custom-analytics"
79
+ }
80
+ ]
81
+ }
82
+ ```
83
+
84
+ ### Setup Workflow
85
+
86
+ ```bash
87
+ # 1. Navigate to your plugin/theme repo
88
+ cd ~/projects/bu-custom-analytics
89
+
90
+ # 2. Install buwp-local
91
+ npm install --save-dev @bostonuniversity/buwp-local
92
+
93
+ # 3. Initialize (auto-generates config with mapping)
94
+ npx buwp-local init --plugin
95
+
96
+ # 4. Start environment
97
+ npx buwp-local start
98
+ ```
99
+
100
+ ### When to Use
101
+
102
+ - ✅ Single plugin or theme development
103
+ - ✅ Coming from wp-env background
104
+ - ✅ Want repo to be fully self-contained
105
+ - ✅ Don't need to test multiple plugins together
106
+
107
+ ### Xdebug Configuration
108
+
109
+ See [Pattern A in XDEBUG.md](XDEBUG.md#pattern-a-in-repo-development) for IDE-specific pathMappings.
110
+
111
+ ---
112
+
113
+ ## Pattern B: Sandbox Coordination
114
+
115
+ **Use Case:** Multiple repos coordinated from a "base camp" directory
116
+
117
+ ### Description
118
+
119
+ buwp-local is installed in a **separate "base camp" directory** that doesn't contain any WordPress code. This directory coordinates multiple plugin/theme repos by mapping them into a shared WordPress instance. The repos themselves remain pure and unaware of buwp-local.
120
+
121
+ **Key concept:** Like the traditional VM sandbox development environment, but using Docker and volume mappings instead of SFTP.
122
+
123
+ **Good for:**
124
+ - Working on multiple repos that interact
125
+ - Keeping repos free of development tool dependencies
126
+
127
+ ### Pros & Cons
128
+
129
+ **Pros:**
130
+ - ✅ Repos stay pure (no buwp-local installation needed)
131
+ - ✅ Work on multiple plugins/themes simultaneously
132
+ - ✅ Test plugin interactions in realistic environment
133
+ - ✅ Team can share base camp configuration
134
+ - ✅ Site content and database available across repos in single project
135
+
136
+ **Cons:**
137
+ - ❌ Requires hand-editing config file for mappings
138
+ - ❌ No WordPress core context in IDE (unless using Pattern C)
139
+ - ❌ Slightly more complex initial setup
140
+
141
+ ### Example Configuration
142
+
143
+ **Directory Structure:**
144
+ ```
145
+ ~/projects/
146
+ ├── bu-sandbox/ ← "Base camp" (owns buwp-local)
147
+ │ ├── .buwp-local.json ← Hand-edited mappings
148
+ │ ├── .env.local ← Credentials (optional)
149
+ │ ├── package.json ← npm install buwp-local here
150
+ │ └── node_modules/
151
+ │ └── @bostonuniversity/buwp-local/
152
+
153
+ ├── bu-navigation/ ← Pure repo (no buwp-local)
154
+ │ ├── bu-navigation.php
155
+ │ └── includes/
156
+
157
+ ├── bu-slideshow/ ← Pure repo (no buwp-local)
158
+ │ ├── bu-slideshow.php
159
+ │ └── assets/
160
+
161
+ └── responsive-framework/ ← Pure repo (no buwp-local)
162
+ ├── style.css
163
+ └── functions.php
164
+
165
+ Container (all repos mapped into one WordPress):
166
+ /var/www/html/ (Docker volume)
167
+ └── wp-content/
168
+ ├── plugins/
169
+ │ ├── bu-navigation/ (→ ~/projects/bu-navigation)
170
+ │ └── bu-slideshow/ (→ ~/projects/bu-slideshow)
171
+ └── themes/
172
+ └── responsive-framework/ (→ ~/projects/responsive-framework)
173
+ ```
174
+
175
+ **Configuration File (`~/projects/bu-sandbox/.buwp-local.json`):**
176
+
177
+ Using **absolute paths** (most common, explicit):
178
+ ```json
179
+ {
180
+ "projectName": "bu-sandbox",
181
+ "hostname": "bu-sandbox.local",
182
+ "multisite": true,
183
+ "services": {
184
+ "redis": true,
185
+ "s3proxy": true,
186
+ "shibboleth": true
187
+ },
188
+ "ports": {
189
+ "http": 80,
190
+ "https": 443,
191
+ "db": 3306,
192
+ "redis": 6379
193
+ },
194
+ "mappings": [
195
+ {
196
+ "local": "/Users/username/projects/bu-navigation",
197
+ "container": "/var/www/html/wp-content/plugins/bu-navigation"
198
+ },
199
+ {
200
+ "local": "/Users/username/projects/bu-slideshow",
201
+ "container": "/var/www/html/wp-content/plugins/bu-slideshow"
202
+ },
203
+ {
204
+ "local": "/Users/username/projects/responsive-framework",
205
+ "container": "/var/www/html/wp-content/themes/responsive-framework"
206
+ }
207
+ ],
208
+ "env": {
209
+ "WP_DEBUG": true,
210
+ "XDEBUG": false
211
+ }
212
+ }
213
+ ```
214
+
215
+ Using **relative paths** (if repos are siblings to base camp):
216
+ ```json
217
+ {
218
+ "projectName": "bu-sandbox",
219
+ "hostname": "bu-sandbox.local",
220
+ "mappings": [
221
+ {
222
+ "local": "../bu-navigation",
223
+ "container": "/var/www/html/wp-content/plugins/bu-navigation"
224
+ },
225
+ {
226
+ "local": "../bu-slideshow",
227
+ "container": "/var/www/html/wp-content/plugins/bu-slideshow"
228
+ },
229
+ {
230
+ "local": "../responsive-framework",
231
+ "container": "/var/www/html/wp-content/themes/responsive-framework"
232
+ }
233
+ ]
234
+ }
235
+ ```
236
+
237
+ ### Setup Workflow
238
+
239
+ ```bash
240
+ # 1. Create base camp directory
241
+ mkdir ~/projects/bu-sandbox
242
+ cd ~/projects/bu-sandbox
243
+
244
+ # 2. Initialize npm project and install buwp-local
245
+ npm init -y
246
+ npm install --save-dev @bostonuniversity/buwp-local
247
+
248
+ # 3. Initialize in sandbox mode
249
+ npx buwp-local init --sandbox
250
+
251
+ # 4. Hand-edit .buwp-local.json to add repo mappings
252
+ # (See example configurations above)
253
+
254
+ # 5. Start environment
255
+ npx buwp-local start
256
+
257
+ # 6. Develop in your repos (bu-navigation, bu-slideshow, etc.)
258
+ # Changes sync automatically via volume mappings
259
+ ```
260
+
261
+ ### When to Use
262
+
263
+ - ✅ Developing multiple BU plugins/themes together
264
+ - ✅ Testing plugin interactions (navigation + slideshow + theme)
265
+ - ✅ Want repos to stay clean (no dev tool dependencies)
266
+ - ✅ Transitioning from VM sandbox workflow
267
+
268
+ ### Xdebug Configuration
269
+
270
+ See [Pattern B in XDEBUG.md](XDEBUG.md#pattern-b-sandbox-coordination) for multi-workspace pathMappings.
271
+
272
+ ---
273
+
274
+ ## Pattern C: Monolithic Sandbox
275
+
276
+ **Use Case:** Full WordPress codebase for complete IDE intelligence
277
+
278
+ ### Description
279
+
280
+ A variant of Pattern B where the base camp maps the **entire WordPress installation** instead of selective plugins/themes. This provides complete IDE context (autocomplete for WordPress core, go-to-definition across all code) at the cost of more complex setup and slower filesystem performance.
281
+
282
+ **Good for:**
283
+ - Advanced IDE users (PHPStorm, Zed)
284
+ - Complex debugging across multiple codebases
285
+ - Need to edit WordPress core or dependencies
286
+ - Want full codebase navigation
287
+
288
+ ### Pros & Cons
289
+
290
+ **Pros:**
291
+ - ✅ Full WordPress core autocomplete in IDE
292
+ - ✅ Go-to-definition works across all code
293
+ - ✅ Can edit any file (core, plugins, themes)
294
+ - ✅ Step debug the entire codebase
295
+ - ✅ Complete codebase context
296
+
297
+ **Cons:**
298
+ - ❌ Complex initial setup
299
+ - ❌ Must manage all code updates locally
300
+ - ❌ Risk of accidentally editing core files
301
+ - ❌ Potentially Slower volume performance (large mapping)
302
+
303
+ ### Example Configuration
304
+
305
+ **Directory Structure:**
306
+ ```
307
+ ~/projects/
308
+ ├── bu-sandbox-full/ ← Base camp
309
+ │ ├── .buwp-local.json ← Points to wordpress-build
310
+ │ ├── package.json ← Has buwp-local
311
+ │ ├── node_modules/
312
+ │ └── wordpress-build/ ← Full WordPress ← Mapped to container
313
+ │ ├── wp-admin/
314
+ │ ├── wp-content/
315
+ │ │ ├── plugins/
316
+ │ │ │ ├── bu-navigation/
317
+ │ │ │ ├── bu-slideshow/
318
+ │ │ │ └── ... (all plugins)
319
+ │ │ ├── themes/
320
+ │ │ │ └── ... (all themes)
321
+ │ │ └── mu-plugins/
322
+ │ ├── wp-includes/
323
+ │ └── wp-config.php
324
+
325
+ Container:
326
+ /var/www/html/ (→ entire wordpress-build directory)
327
+ ```
328
+
329
+ **Configuration File (`~/projects/bu-sandbox-full/.buwp-local.json`):**
330
+
331
+ Using **relative path** to wordpress-build:
332
+ ```json
333
+ {
334
+ "projectName": "bu-sandbox-full",
335
+ "hostname": "bu-sandbox-full.local",
336
+ "multisite": true,
337
+ "services": {
338
+ "redis": true,
339
+ "s3proxy": true,
340
+ "shibboleth": true
341
+ },
342
+ "ports": {
343
+ "http": 80,
344
+ "https": 443,
345
+ "db": 3306,
346
+ "redis": 6379
347
+ },
348
+ "mappings": [
349
+ {
350
+ "local": "./wordpress-build",
351
+ "container": "/var/www/html"
352
+ }
353
+ ],
354
+ "env": {
355
+ "WP_DEBUG": true,
356
+ "XDEBUG": true
357
+ }
358
+ }
359
+ ```
360
+
361
+ Using **absolute path**:
362
+ ```json
363
+ {
364
+ "projectName": "bu-sandbox-full",
365
+ "hostname": "bu-sandbox-full.local",
366
+ "mappings": [
367
+ {
368
+ "local": "/Users/username/projects/bu-sandbox-full/wordpress-build",
369
+ "container": "/var/www/html"
370
+ }
371
+ ]
372
+ }
373
+ ```
374
+
375
+ ### Setup Workflow
376
+
377
+ ```bash
378
+ # 1. Create base camp directory
379
+ mkdir ~/projects/bu-sandbox-full
380
+ cd ~/projects/bu-sandbox-full
381
+
382
+ # 2. Build or clone full WordPress
383
+ # Method depends on your organization:
384
+ # - Clone WordPress core
385
+ # - Clone all BU plugins/themes into wp-content/
386
+ # - Run any build scripts (composer, npm)
387
+ # - Or: Copy from existing dev environment
388
+
389
+ # Example structure:
390
+ mkdir wordpress-build
391
+ cd wordpress-build
392
+ # ... set up WordPress core + all plugins/themes ...
393
+
394
+ # 3. Back to base camp, initialize npm and install buwp-local
395
+ cd ~/projects/bu-sandbox-full
396
+ npm init -y
397
+ npm install --save-dev @bostonuniversity/buwp-local
398
+
399
+ # 4. Initialize in sandbox mode
400
+ npx buwp-local init --sandbox
401
+
402
+ # 5. Edit .buwp-local.json to map wordpress-build
403
+ # (See example configuration above)
404
+
405
+ # 6. Start environment
406
+ npx buwp-local start
407
+
408
+ # 7. Open IDE with wordpress-build as project root
409
+ # Full WordPress codebase is now available for autocomplete
410
+ ```
411
+
412
+ ### When to Use
413
+
414
+ - ✅ Using advanced IDE (Zed, PHPStorm with deep inspection)
415
+ - ✅ Need autocomplete for WordPress core functions
416
+ - ✅ Debugging complex issues across plugins + core
417
+ - ✅ Want complete codebase navigation
418
+ - ✅ Willing to manage full WordPress build locally
419
+ - ✅ Have fast disk I/O (SSD recommended)
420
+
421
+ ### Important Considerations
422
+
423
+ **WordPress Management:**
424
+ - You're responsible for build updates and maintenance
425
+
426
+ **Performance:**
427
+ - Largest mapping = slowest volume I/O on macOS
428
+ - Initial sync may take time (large file count)
429
+ - File watchers may struggle with large codebases
430
+ - Linux performs better than macOS for large mappings
431
+
432
+ ### Xdebug Configuration
433
+
434
+ See [Pattern C in XDEBUG.md](XDEBUG.md#pattern-c-monolithic-sandbox) for complete IDE context pathMappings.
435
+
436
+ ---
437
+
438
+ ## Choosing a Pattern
439
+
440
+ ### Quick Comparison Table
441
+
442
+ | Pattern | buwp-local Location | IDE Context | Setup | Volume Perf | Best For |
443
+ |---------|---------------------|-------------|-------|-------------|----------|
444
+ | **A: In-Repo** | Inside plugin/theme repo | Your code only | ⭐ Easy | ⭐⭐⭐ Fast | wp-env users, single repo |
445
+ | **B: Sandbox** | Separate base camp | Your repos only | ⭐⭐ Medium | ⭐⭐ Good | Multiple repos, teams |
446
+ | **C: Monolithic** | Separate base camp | Everything | ⭐⭐⭐⭐ Advanced | ⭐ Slower | Full IDE context |
447
+
448
+ ### Recommendation by Scenario
449
+
450
+ **Coming from wp-env?** → Pattern A (familiar workflow)
451
+ **Coming from VM sandbox?** → Pattern B (similar concept, better maintainability)
452
+ **Multiple BU plugins to test?** → Pattern B (coordination from base camp)
453
+ **Team development?** → Pattern B (shared base camp config)
454
+ **Need WordPress core autocomplete?** → Pattern C (monolithic sandbox)
455
+ **Single open-source plugin?** → Pattern A (self-contained repo)
456
+
457
+ You can mix patterns - some repos use Pattern A while others coordinate through Pattern B base camp.
458
+
459
+ ---
460
+
461
+ ## Related Documentation
462
+
463
+ - **[XDEBUG.md](XDEBUG.md)** - Pattern-specific Xdebug configuration
464
+ - **[MULTI_PROJECT.md](MULTI_PROJECT.md)** - Isolated vs shared environment strategies
465
+ - **[GETTING_STARTED.md](GETTING_STARTED.md)** - Initial setup guide
466
+ - **[COMMANDS.md](COMMANDS.md)** - CLI reference