Scaffold CLI Reference
The Scaffold CLI is your single command to manage WPZylos plugins.
Prerequisites
| Tool | Required | Notes |
|---|---|---|
| PHP 8.0+ | Good: Yes | Runtime for all operations |
| Composer 2.0+ | Good: Yes | Dependency management |
| PowerShell | Good: Windows | Pre-installed on Windows 10/11 |
| Bash | Good: Unix | Pre-installed on Linux/Mac; Git Bash for Windows |
Running the CLI
Windows (PowerShell)
Open PowerShell (search "PowerShell" in Start menu):
.\scaffold.ps1 # Interactive menu
.\scaffold.ps1 init # Initialize plugin
.\scaffold.ps1 build # Build for production
Windows (Command Prompt)
Open Command Prompt (cmd.exe) and use:
powershell -ExecutionPolicy Bypass -File scaffold.ps1
powershell -ExecutionPolicy Bypass -File scaffold.ps1 init
powershell -ExecutionPolicy Bypass -File scaffold.ps1 build
Why the extra command? Command Prompt doesn't execute
.ps1files directly. We invoke PowerShell with-ExecutionPolicy Bypassto allow script execution.
Linux / Mac
chmod +x scaffold.sh # Make executable (first time)
./scaffold.sh # Interactive menu
./scaffold.sh init # Initialize plugin
./scaffold.sh build # Build for production
Git Bash (Windows)
Git Bash provides a Bash shell on Windows:
chmod +x scaffold.sh # Make executable (first time)
./scaffold.sh # Interactive menu
./scaffold.sh init # Initialize plugin
./scaffold.sh build # Build for production
Get Git Bash: Install Git for Windows - Git Bash is included.
Interactive Mode
Running the CLI without arguments shows a menu:
██╗ ██╗██████╗ ███████╗██╗ ██╗██╗ ██████╗ ███████╗
██║ ██║██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██╔═══██╗██╔════╝
██║ █╗ ██║██████╔╝ ███╔╝ ╚████╔╝ ██║ ██║ ██║███████╗
██║███╗██║██╔═══╝ ███╔╝ ╚██╔╝ ██║ ██║ ██║╚════██║
╚███╔███╔╝██║ ███████╗ ██║ ███████╗╚██████╔╝███████║
╚══╝╚══╝ ╚═╝ ╚══════╝ ╚═╝ ╚══════╝ ╚═════╝ ╚══════╝
WPZylos Scaffold CLI v1.0.0
Current Plugin: My Awesome Plugin
Slug: my-awesome-plugin
What would you like to do?
[1] Initialize Plugin
[2] Build for Production
[0] Exit
Init Command
The intelligent init script handles all scenarios:
| Scenario | Behavior |
|---|---|
| Fresh install | Detects my-plugin.php, uses scaffold defaults |
| Re-configure | Loads .plugin-config.json, shows current values as defaults |
| Config deleted | Auto-detects plugin from *.php with "Plugin Name:" header |
| Partial update | Only changes modified values, shows "Skipped" for unchanged |
Fresh Install Example
Fresh scaffold detected.
Enter your plugin display name (or press Enter to keep current):
> Plugin Name [My Plugin]: My Awesome Plugin
Derived/Current values (press Enter to accept, or type to override):
Plugin Slug [my-awesome-plugin]:
PHP Namespace [MyAwesomePlugin]: Starter\MyAwesomePlugin
Scoper Prefix [my_awesome_plugin]:
Database Prefix [MyAwesomePlugin_]: map_
Author information (press Enter to keep current):
Author Name [Your Name]: MyCompany
Author URI [https://example.com]: https://MyCompany.com
Plugin URI [https://example.com/my-awesome-plugin]:
Vendor Name (for composer) [MyCompany]:
Version [1.0.0]: 1.0.0
[1/10] Replacing display name... Done
[2/10] Replacing plugin slug... Done
...
[8/10] Updating version... Done
Re-Configure Example
Current Configuration:
Plugin Name: My Awesome Plugin
Slug: my-awesome-plugin
Namespace: Starter\MyAwesomePlugin
DB Prefix: map_
Vendor: MyCompany
You can update any value or press Enter to keep current.
> Plugin Name [My Awesome Plugin]:
PHP Namespace [Starter\MyAwesomePlugin]: MyCompany\MyAwesomePlugin
[1/10] Replacing display name... Skipped
[2/10] Replacing plugin slug... Skipped
[3/10] Replacing namespace... Done
...
Namespace Support
You can use nested namespaces:
MyAwesomePlugin(simple)Starter\MyAwesomePlugin(vendor prefixed)MyCompany\WP\Bra\Calculator(deep nesting)
Build Command
Runs the production build pipeline.
Build Options
PowerShell:
.\scaffold.ps1 build # Full build
.\scaffold.ps1 build -SkipQA # Skip QA checks
.\scaffold.ps1 build -SkipScoper # Dev build (no scoping)
Command Prompt:
powershell -ExecutionPolicy Bypass -File scaffold.ps1 build
powershell -ExecutionPolicy Bypass -File scaffold.ps1 build -SkipQA
powershell -ExecutionPolicy Bypass -File scaffold.ps1 build -SkipScoper
Bash (Linux/Mac/Git Bash):
./scaffold.sh build # Full build
./scaffold.sh build --skip-qa # Skip QA checks
./scaffold.sh build --skip-scoper # Dev build (no scoping)
Build Pipeline
- Clean - Remove previous build artifacts
- phpcbf - Auto-fix code style (PSR12)
- phpstan - Static analysis
- Dependencies - Install production dependencies
- PHP-Scoper - Namespace isolation
- Package - Create versioned ZIP in
dist/
Build Output
dist/
+-- my-awesome-plugin-1.0.0.zip
Intelligent Build Features
- Smart File Discovery: Automatically detects project files/folders and prompts for unknown items
- Preference Persistence: Saves include/exclude choices to
.plugin-config.jsonfor future builds - Auto-Versioning: Suggests next patch version (e.g., 1.0.1) based on existing ZIPs in
dist/ - Artifact Preservation: Preserves the
dist/directory with previous builds
Configuration File
The init script saves configuration to .plugin-config.json:
{
"initialized": true,
"timestamp": "2026-02-04T16:00:00+05:00",
"plugin": {
"name": "My Awesome Plugin",
"slug": "my-awesome-plugin",
"namespace": "Starter\\MyAwesomePlugin",
"scoperPrefix": "my_awesome_plugin",
"dbPrefix": "map_",
"version": "1.0.0",
"mainFile": "my-awesome-plugin.php"
},
"author": {
"name": "MyCompany",
"uri": "https://MyCompany.com"
},
"composer": {
"vendor": "MyCompany",
"name": "MyCompany/my-awesome-plugin"
}
}
Non-Interactive Mode (CI/CD)
PowerShell:
.\scaffold.ps1 init -NonInteractive `
-PluginName "My Plugin" `
-PluginSlug "my-plugin" `
-Namespace "MyCompany\MyPlugin" `
-VendorName "mycompany"
Command Prompt:
powershell -ExecutionPolicy Bypass -File scaffold.ps1 init -NonInteractive -PluginName "My Plugin" -PluginSlug "my-plugin" -Namespace "MyCompany\MyPlugin" -VendorName "mycompany"
Files Modified by Init
| File | Changes |
|---|---|
{slug}.php | Plugin headers, PluginContext config, version |
composer.json | Package name, namespace in autoload |
scoper.inc.php | Scoper prefix variable |
uninstall.php | Context configuration |
readme.txt | Author username, Stable tag version |
.plugin-config.json | Created with all settings including version |
Troubleshooting
"Select an app to open this .ps1 file"
Problem: You're running from Command Prompt, not PowerShell.
Solution: Use the Command Prompt syntax:
powershell -ExecutionPolicy Bypass -File scaffold.ps1 init
"Cannot detect plugin state"
The script expects either:
my-plugin.php(fresh install).plugin-config.json(configured plugin)- A
*.phpfile with "Plugin Name:" header
Namespace not updating
Ensure you're using the correct backslash format:
- Correct:
Starter\MyAwesomePlugin - Incorrect:
Starter\\MyAwesomePlugin(double backslash)
Build fails
Check that:
- PHP 8.0+ is available (
php -v) - Composer dependencies are installed (
composer install) .plugin-config.jsonexists (run init first)
ExecutionPolicy error
If you get an ExecutionPolicy error in PowerShell:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Or use the bypass syntax from Command Prompt.