Usage
Customize and build your WPZylos plugin using the Scaffold CLI.
Prerequisites
| Tool | Required | Notes |
|---|---|---|
| PHP 8.0+ | Good: Yes | Check with php -v |
| Composer 2.0+ | Good: Yes | Check with composer -V |
| PowerShell | Windows | Pre-installed on Windows 10/11 |
| Bash | Unix | Pre-installed on Linux/Mac; Git Bash for Windows |
Running the Scaffold CLI
Option 1: PowerShell (Windows 10/11)
Open Windows PowerShell (search "PowerShell" in Start menu):
.\scaffold.ps1 # Interactive menu
.\scaffold.ps1 init # Initialize plugin
.\scaffold.ps1 build # Build for production
Option 2: Command Prompt (Windows)
Open Command Prompt (cmd.exe). Since .ps1 files don't run directly in cmd, use:
powershell -ExecutionPolicy Bypass -File scaffold.ps1
powershell -ExecutionPolicy Bypass -File scaffold.ps1 init
powershell -ExecutionPolicy Bypass -File scaffold.ps1 build
Option 3: Bash (Linux/Mac/Git Bash)
For Linux, macOS, or Git Bash on Windows (install Git for Windows):
chmod +x scaffold.sh # Make executable (first time only)
./scaffold.sh # Interactive menu
./scaffold.sh init # Initialize plugin
./scaffold.sh build # Build for production
Git Bash alternative: If
./scaffold.shdoesn't work, trybash scaffold.sh
Initialization
Running scaffold init prompts for:
| Prompt | Example | Description |
|---|---|---|
| Plugin Name | My Awesome Plugin | Display name |
| Plugin Slug | my-awesome-plugin | Lowercase, hyphenated |
| Namespace | MyAwesomePlugin | PascalCase PHP namespace |
| Scoper Prefix | my_awesome_plugin | For PHP-Scoper isolation |
| Database Prefix | wpb_ | For DB tables and options |
| Author Name | Your Name | Plugin author |
Namespace Support
You can use nested namespaces with backslashes:
MyAwesomePlugin # Simple
Starter\MyAwesomePlugin # Vendor prefixed
MyCompany\WP\Bra\Calculator # Deep nesting
Re-Configuration
The init script is intelligent - run it again to update values:
Current Configuration:
Plugin Name: My Awesome Plugin
Slug: my-awesome-plugin
Namespace: Starter\MyAwesomePlugin
You can update any value or press Enter to keep current.
> Plugin Name [My Awesome Plugin]:
PHP Namespace [Starter\MyAwesomePlugin]: MyCompany\MyAwesomePlugin
Only changed values are replaced (others show "Skipped").
Configuration File
After init, .plugin-config.json stores your settings:
{
"plugin": {
"name": "My Awesome Plugin",
"slug": "my-awesome-plugin",
"namespace": "Starter\\MyAwesomePlugin"
}
}
This file is used by scaffold build.
Building for Production
Option 1: PowerShell (Windows)
.\scaffold.ps1 build # Full build with QA
.\scaffold.ps1 build -SkipQA # Skip phpcbf/phpstan
.\scaffold.ps1 build -SkipScoper # Dev build (no scoping)
Option 2: Command Prompt (Windows)
powershell -ExecutionPolicy Bypass -File scaffold.ps1 build
powershell -ExecutionPolicy Bypass -File scaffold.ps1 build -SkipQA
powershell -ExecutionPolicy Bypass -File scaffold.ps1 build -SkipScoper
Option 3: Bash (Linux/Mac/Git Bash)
./scaffold.sh build # Full build with QA
./scaffold.sh build --skip-qa # Skip phpcbf/phpstan
./scaffold.sh build --skip-scoper # Dev build (no scoping)
Build Pipeline
- Clean artifacts
- Run phpcbf (PSR12)
- Run phpstan
- Install production dependencies
- Run PHP-Scoper
- Create versioned ZIP in
dist/
Next Steps
- CLI Reference - Complete CLI documentation
- Configuration - Configure options
- API Reference - Available methods
- Walkthrough - Complete tutorial