81 lines
3.7 KiB
Markdown
81 lines
3.7 KiB
Markdown
# Easy WordPress Bootstrap (Windows + Herd)
|
||
|
||
PowerShell companion to the macOS bootstrap script. It provisions a full WordPress development site backed by Laravel Herd and DBngin (or any local MySQL/MariaDB server) with a single command.
|
||
|
||
## Included Files
|
||
|
||
- `wp-bootstrap.ps1` – main PowerShell script.
|
||
- `wp-cli.phar` – bundled WP-CLI used by the script when `wp` is not installed globally.
|
||
- `plugins.json` – default plugin manifest; copy/override per project if you need a different set.
|
||
|
||
## Prerequisites
|
||
|
||
- Windows 10/11 with PowerShell 7 (`pwsh`) recommended.
|
||
- [Laravel Herd for Windows](https://herd.laravel.com/) installed so PHP is available (the script auto-detects Herd’s `php.exe`).
|
||
- DBngin or another MySQL/MariaDB server running locally, with `mysql.exe` available in `PATH`.
|
||
- Git for cloning the starter theme.
|
||
- Composer and npm in `PATH` so theme dependencies can be installed and built (the script warns and skips if they are missing).
|
||
|
||
## First-Time Setup
|
||
|
||
1. Allow local PowerShell scripts (only needs to be done once for your profile):
|
||
|
||
```powershell
|
||
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
|
||
```
|
||
|
||
2. Copy the sample rc file and adjust values that should become your defaults:
|
||
|
||
```powershell
|
||
Copy-Item ..\wp-bootstraprc.example $HOME\.wp-bootstraprc
|
||
```
|
||
|
||
3. Leave `wp-cli.phar` in the same folder as `wp-bootstrap.ps1` (or update the `WP_CLI_PHAR` entry in your rc file to point elsewhere).
|
||
|
||
## Running a Bootstrap
|
||
|
||
From this directory, run:
|
||
|
||
```powershell
|
||
pwsh -File .\wp-bootstrap.ps1 -ProjectName "Client Site"
|
||
```
|
||
|
||
Optional parameters (all may also be supplied via `~\.wp-bootstraprc`):
|
||
|
||
- `-AdminUser`
|
||
- `-AdminEmail`
|
||
- `-ThemeStarterRepo`
|
||
- `-HerdWorkspace`
|
||
- `-LocalTld`
|
||
- `-MysqlHost`
|
||
- `-MysqlPort`
|
||
- `-MysqlRootUser`
|
||
- `-MysqlRootPass`
|
||
|
||
Omit parameters to fall back to your rc defaults. The script prints the detected configuration before it runs and exits early if required inputs are still missing.
|
||
|
||
## What the Script Does
|
||
|
||
- Creates a sanitized project folder in your Herd workspace and reports the local URL.
|
||
- Validates MySQL root credentials, creates the database/user, and confirms the new user can connect.
|
||
- Downloads WordPress core, generates `wp-config.php`, shuffles salts, sets permalinks, creates Home/News pages, and assigns them.
|
||
- Ensures a standard `.htaccess` exists for Apache-friendly rewrites.
|
||
- Clones the starter theme with shallow history, strips `.git`, reinitializes the repo, sets an optional remote, and activates the theme.
|
||
- Installs/activates plugins pulled from `plugins.json`, preferring a project-local manifest when present.
|
||
- Runs `composer install`, `npm install`, and `npm run build` inside the theme when those tools are available.
|
||
- Writes a `bootstrap-summary.txt` to the project root and logs plugin installs to `wp-content/plugin-bootstrap.log`.
|
||
|
||
## Plugin Manifest Details
|
||
|
||
`plugins.json` entries can be WordPress.org slugs or zip URLs (including private artifacts). Place a tailored `plugins.json` in your project directory to override the repository default for a single site.
|
||
|
||
## Troubleshooting
|
||
|
||
- **WP-CLI** – ensure `wp-cli.phar` lives beside the script or set `WP_CLI_PHAR` in `~\.wp-bootstraprc` to an absolute path.
|
||
- **MySQL connectivity** – verify the server is running, your root user matches the rc values, and Windows Firewall allows the connection.
|
||
- **Composer/NPM missing** – install them via Scoop/winget/Homebrew on Windows, or remove their commands from the script if you do not build theme assets.
|
||
- **Permissions** – confirm Herd has access to the project folder and that the execution policy change succeeded.
|
||
|
||
---
|
||
DIY-first policy: keep `plugins.json` lean; add heavier stacks only when the project truly needs them.
|