PHPackages                             wpdiggerstudio/wpzylos-scaffold - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. wpdiggerstudio/wpzylos-scaffold

ActiveWordpress-plugin[Templating &amp; Views](/categories/templating)

wpdiggerstudio/wpzylos-scaffold
===============================

Template repository for creating production-ready WPZylos-based WordPress plugins with MVC architecture, dependency injection, and PHP-Scoper namespace isolation

v1.1.0(3mo ago)011MITPowerShellPHP ^8.0CI passing

Since Feb 1Pushed 3mo agoCompare

[ Source](https://github.com/WPDiggerStudio/wpzylos-scaffold)[ Packagist](https://packagist.org/packages/wpdiggerstudio/wpzylos-scaffold)[ Docs](https://github.com/WPDiggerStudio/wpzylos-scaffold)[ Fund](https://www.paypal.com/donate/?hosted_button_id=66U4L3HG4TLCC)[ RSS](/packages/wpdiggerstudio-wpzylos-scaffold/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (18)Versions (3)Used By (0)

WPZylos Scaffold
================

[](#wpzylos-scaffold)

[![PHP Version](https://camo.githubusercontent.com/911a83e2aa6fe73660ab613629a95c76622bf03049a7344e80c5ea72d4ef9c7d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e302d626c7565)](https://php.net)[![WordPress](https://camo.githubusercontent.com/c6eb04a9023f8c55d4c36d97df72aa48a6958807a011b582664ddb6b1410e3a3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f776f726470726573732d362e302532422d626c7565)](https://wordpress.org)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)[![GitHub](https://camo.githubusercontent.com/dbe820b98864e115173c422b9472b725cfa678bee03b66ff2c453dad95a3d20b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4769744875622d575044696767657253747564696f2d3138313731373f6c6f676f3d676974687562)](https://github.com/WPDiggerStudio/wpzylos-scaffold)

Template repository for creating **production-ready WordPress plugins** with MVC architecture and PHP-Scoper namespace isolation.

📖 **[Full Documentation](https://wpzylos.com)** | 🐛 **[Report Issues](https://github.com/WPDiggerStudio/wpzylos-scaffold/issues)**

---

✨ Features
----------

[](#-features)

- **Complete MVC Structure** — Controllers, Services, Views, Routes
- **PSR-4 Autoloading** — Modern PHP namespace organization
- **PHP-Scoper Ready** — Pre-configured namespace isolation for multi-plugin compatibility
- **Service Providers** — Modular dependency injection
- **Database Migrations** — Version-controlled schema changes
- **WordPress Compliant** — Proper headers, MIT license, readme.txt
- **Intelligent CLI** — Version prompting, smart file discovery, auto-versioning
- **Build Pipeline** — Scaffold CLI with QA checks and ZIP creation
- **Security First** — Nonce verification, capability checks, input sanitization

---

📋 Requirements
--------------

[](#-requirements)

RequirementVersionPHP^8.0WordPress6.0+Composer2.0+WP-CLIOptional---

🚀 Quick Start
-------------

[](#-quick-start)

### Option 1: Use as GitHub Template

[](#option-1-use-as-github-template)

Click **"Use this template"** on GitHub to create a new repository.

### Option 2: Composer Create Project

[](#option-2-composer-create-project)

```
cd /path/to/wordpress/wp-content/plugins
composer create-project wpdiggerstudio/wpzylos-scaffold your-plugin-name
cd your-plugin-name
```

### Option 3: Clone and Customize

[](#option-3-clone-and-customize)

```
git clone https://github.com/WPDiggerStudio/wpzylos-scaffold.git your-plugin-name
cd your-plugin-name
rm -rf .git
composer install
```

### Initialize Your Plugin (Recommended)

[](#initialize-your-plugin-recommended)

After creating your project, run the **Scaffold CLI** to customize and manage your plugin.

#### Option 1: PowerShell (Windows 10/11)

[](#option-1-powershell-windows-1011)

Open **Windows PowerShell** (search "PowerShell" in Start menu):

```
.\scaffold.ps1           # Interactive menu
.\scaffold.ps1 init      # Initialize plugin directly
.\scaffold.ps1 build     # Build for production directly
```

#### Option 2: Command Prompt (Windows)

[](#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)

[](#option-3-bash-linuxmacgit-bash)

For **Linux**, **macOS**, or **Git Bash on Windows** (install [Git for Windows](https://git-scm.com/download/win)):

```
chmod +x scaffold.sh     # Make executable (first time only)
./scaffold.sh            # Interactive menu
./scaffold.sh init       # Initialize plugin directly
./scaffold.sh build      # Build for production directly
```

> **Git Bash alternative:** If `./scaffold.sh` doesn't work, try `bash scaffold.sh`

---

The **intelligent init script** handles all scenarios:

ScenarioBehavior**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**Features:**

- **Version Prompting:** Sets initial version and updates plugin header + PluginContext
- **Namespace support:** Supports nested namespaces like `WPDigger\WPBraCalculator`

---

📁 Project Structure
-------------------

[](#-project-structure)

```
your-plugin/
├── app/                        # Application code (PSR-4: YourPlugin\)
│   ├── Core/
│   │   └── PluginContext.php   # Plugin identity (slug, prefix, text domain)
│   ├── Lifecycle/
│   │   ├── Activator.php       # Activation logic
│   │   ├── Deactivator.php     # Deactivation logic
│   │   └── Uninstaller.php     # Uninstall cleanup
│   └── Support/
│       └── helpers.php         # Global helper functions
├── bootstrap/
│   └── app.php                 # Application bootstrap & service providers
├── config/
│   └── app.php                 # Application configuration
├── database/
│   └── migrations/             # Database migrations
├── resources/
│   ├── lang/                   # Translation files
│   └── views/                  # PHP view templates
├── routes/
│   └── web.php                 # Route definitions
├── tests/
│   └── Unit/                   # PHPUnit tests
├── scaffold.ps1                # Scaffold CLI (Windows)
├── scaffold.sh                 # Scaffold CLI (Linux/Mac)
├── .scripts/                   # CLI scripts
│   ├── init-plugin.ps1/.sh     # Initialization logic
│   └── build.ps1/.sh           # Build pipeline logic
├── your-plugin.php             # Main plugin entry point
├── uninstall.php               # WordPress uninstall handler
├── scoper.inc.php              # PHP-Scoper configuration
├── composer.json               # Dependencies
└── readme.txt                  # WordPress.org readme

```

---

🔧 Customization
---------------

[](#-customization)

### Automated (Recommended)

[](#automated-recommended)

Run the Scaffold CLI for automated setup:

**PowerShell:**

```
.\scaffold.ps1 init
```

**Command Prompt:**

```
powershell -ExecutionPolicy Bypass -File scaffold.ps1 init
```

**Linux/Mac/Git Bash:**

```
./scaffold.sh init
```

### Manual

[](#manual)

If you prefer manual customization, perform search and replace:

FindReplace WithDescription`my-plugin``your-plugin`Plugin slug (lowercase, hyphenated)`my_plugin``your_plugin`Scoper prefix (lowercase, underscored)`MyPlugin``YourPlugin`PHP namespace (PascalCase)`myplugin_``yourplugin_`Database/option prefix`My Plugin``Your Plugin`Display name#### Files to Update

[](#files-to-update)

1. **`your-plugin.php`** — Plugin headers, PluginContext configuration
2. **`composer.json`** — Package name, namespace in autoload
3. **`scoper.inc.php`** — Scoper prefix variable
4. **`.plugin-config.json`** — Created by init, used by build
5. **`uninstall.php`** — Context configuration

---

🏗️ Core Components
------------------

[](#️-core-components)

### PluginContext

[](#plugincontext)

The `PluginContext` class (`app/Core/PluginContext.php`) is the **single source of truth** for plugin identity. All framework components use this for prefixing.

```
$context = PluginContext::create([
    'file'       => __FILE__,
    'slug'       => 'your-plugin',
    'prefix'     => 'yourplugin_',
    'textDomain' => 'your-plugin',
    'version'    => '1.0.0',
]);
```

**Available Methods:**

MethodReturnsExample`slug()`Plugin slug`your-plugin``prefix()`Database prefix`yourplugin_``textDomain()`Translation domain`your-plugin``version()`Plugin version`1.0.0``file()`Main plugin file path`/path/to/your-plugin.php``path($relative)`Absolute path`/path/to/your-plugin/config/``url($relative)`Plugin URL`https://site.com/wp-content/plugins/your-plugin/``hook($name)`Prefixed hook name`yourplugin_custom_hook``optionKey($key)`Prefixed option key`yourplugin_settings``transientKey($key)`Prefixed transient key`yourplugin_cache``cronHook($name)`Prefixed cron hook`yourplugin_daily_task``tableName($name)`Full table name`wp_yourplugin_orders``metaKey($key)`Prefixed meta key`_yourplugin_data``assetHandle($handle)`Asset handle`your-plugin-main`### Helper Functions

[](#helper-functions)

Global helpers available after bootstrap (`app/Support/helpers.php`):

```
// Escaping
zylos_e($text);       // esc_html()
zylos_ea($text);      // esc_attr()
zylos_eu($url);       // esc_url()
zylos_ej($text);      // esc_js()
zylos_kses($html);    // wp_kses_post()

// Application
zylos_app();          // Get application instance
zylos_app('service'); // Resolve service from container
context();            // Get PluginContext

// Translation
zylos_m($text);       // __($text, $textDomain)
zylos_em($text);      // echo translated text
```

---

⚙️ Configuration
----------------

[](#️-configuration)

### config/app.php

[](#configappphp)

```
return [
    'name'       => 'Your Plugin',
    'debug'      => defined('WP_DEBUG') && WP_DEBUG,
    'providers'  => [
        // \YourPlugin\Providers\CustomServiceProvider::class,
    ],
    'capability' => 'manage_options',
];
```

### Service Providers

[](#service-providers)

The bootstrap (`bootstrap/app.php`) registers framework service providers in dependency order:

1. **ConfigServiceProvider** — Configuration and .env loading
2. **I18nServiceProvider** — Internationalization
3. **HookServiceProvider** — WordPress hook management
4. **SecurityServiceProvider** — Nonce, Gate, Sanitizer
5. **HttpServiceProvider** — Request, Response, Pipeline
6. **ValidationServiceProvider** — Input validation
7. **ViewsServiceProvider** — Template rendering
8. **DatabaseServiceProvider** — Database connection
9. **MigrationsServiceProvider** — Schema migrations
10. **RoutingServiceProvider** — URL routing
11. **WpCliServiceProvider** — WP-CLI commands (when available)

---

🛤️ Routing
----------

[](#️-routing)

Define routes in `routes/web.php`:

```
use WPZylos\Framework\Routing\Router;

return static function (Router $router): void {
    // Frontend routes
    $router->get('/products', [ProductController::class, 'index'])->name('products.index');
    $router->get('/products/{id}', [ProductController::class, 'show'])->name('products.show');
    $router->post('/cart/add', [CartController::class, 'add'])->name('cart.add');

    // Route groups with middleware
    $router->group(['prefix' => '/account', 'middleware' => AuthMiddleware::class], function (Router $router) {
        $router->get('/dashboard', [AccountController::class, 'dashboard']);
        $router->post('/update', [AccountController::class, 'update']);
    });
};
```

---

🔨 Build &amp; Release
---------------------

[](#-build--release)

### Development

[](#development)

```
composer install          # Install all dependencies
composer test             # Run PHPUnit tests
composer analyze          # Run PHPStan analysis
```

### Production Build

[](#production-build)

Use the Scaffold CLI for production builds:

**Windows (PowerShell):**

```
.\scaffold.ps1 build              # Full build (QA + Scoper + ZIP)
.\scaffold.ps1 build -SkipQA      # Skip code style/analysis checks
.\scaffold.ps1 build -SkipScoper  # Dev build (skip PHP-Scoper)
```

**Windows (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
```

**Linux/Mac (or Git Bash):**

```
./scaffold.sh build              # Full build (QA + Scoper + ZIP)
./scaffold.sh build --skip-qa    # Skip code style/analysis checks
./scaffold.sh build --skip-scoper  # Dev build (skip PHP-Scoper)
```

The build script will:

1. Clean previous build artifacts
2. Run `phpcbf --standard=PSR12` (code style fix)
3. Run `phpstan analyze` (static analysis)
4. Install production dependencies
5. Run PHP-Scoper for namespace isolation
6. Copy required files &amp; rebuild autoloader
7. Remove development files
8. Create versioned ZIP in `dist/`

> **Note:** The build script reads configuration from `.plugin-config.json` (created by `scaffold init`).

**Intelligent Features:**

- **Smart File Discovery:** Automatically detects project files/folders and prompts for unknown items
- **Preference Persistence:** Saves your include/exclude choices for future builds
- **Auto-Versioning:** Suggests next patch version based on existing ZIP files in `dist/`
- **Artifact Preservation:** Preserves the `dist/` directory with previous builds

The production build creates a zip file at `dist/your-plugin-1.0.0.zip` ready for deployment.

### PHP-Scoper

[](#php-scoper)

The scaffold includes pre-configured PHP-Scoper (`scoper.inc.php`) that:

- Prefixes all vendor namespaces for multi-plugin isolation
- Excludes WordPress core functions, classes, and constants
- Excludes your plugin's namespace
- Generates unique build prefixes using git hash

---

🧪 Testing
---------

[](#-testing)

```
# Run all tests
composer test
# Or
./vendor/bin/phpunit

# Run specific test
./vendor/bin/phpunit --filter TestClassName
```

Tests are located in `tests/Unit/`. The test bootstrap is at `tests/bootstrap.php`.

---

🔒 Security
----------

[](#-security)

The scaffold implements WordPress security best practices:

- **Nonce verification** in form submissions
- **Capability checks** for user permissions
- **Prepared statements** for database queries
- **Output escaping** with proper functions
- **Input sanitization** before processing

See the [Security Package](https://github.com/WPDiggerStudio/wpzylos-security) for detailed security utilities.

---

🐛 Troubleshooting
-----------------

[](#-troubleshooting)

### Composer create-project fails

[](#composer-create-project-fails)

```
php -v              # Verify PHP 8.0+
php -m | grep json  # Verify json extension
```

### Namespace/autoloader issues

[](#namespaceautoloader-issues)

```
composer dump-autoload
```

Verify `composer.json` PSR-4 namespace matches your class namespace.

### PHP-Scoper errors

[](#php-scoper-errors)

Check `scoper.inc.php` and ensure WordPress functions are excluded.

### Built plugin crashes

[](#built-plugin-crashes)

Verify WordPress symbols are excluded in scoper configuration.

---

📦 Related Packages
------------------

[](#-related-packages)

PackageDescription[wpzylos-core](https://github.com/WPDiggerStudio/wpzylos-core)Application foundation[wpzylos-container](https://github.com/WPDiggerStudio/wpzylos-container)PSR-11 dependency injection container[wpzylos-config](https://github.com/WPDiggerStudio/wpzylos-config)Configuration management[wpzylos-routing](https://github.com/WPDiggerStudio/wpzylos-routing)URL routing system[wpzylos-database](https://github.com/WPDiggerStudio/wpzylos-database)Database abstraction[wpzylos-migrations](https://github.com/WPDiggerStudio/wpzylos-migrations)Database migrations[wpzylos-hooks](https://github.com/WPDiggerStudio/wpzylos-hooks)WordPress hook management[wpzylos-security](https://github.com/WPDiggerStudio/wpzylos-security)Security utilities[wpzylos-validation](https://github.com/WPDiggerStudio/wpzylos-validation)Input validation[wpzylos-views](https://github.com/WPDiggerStudio/wpzylos-views)Template rendering[wpzylos-http](https://github.com/WPDiggerStudio/wpzylos-http)HTTP request/response[wpzylos-i18n](https://github.com/WPDiggerStudio/wpzylos-i18n)Internationalization[wpzylos-wp-cli](https://github.com/WPDiggerStudio/wpzylos-wp-cli)WP-CLI integration---

📖 Documentation
---------------

[](#-documentation)

For comprehensive documentation, tutorials, and API reference, visit **[wpzylos.com](https://wpzylos.com)**.

---

☕ Support the Project
---------------------

[](#-support-the-project)

If you find this scaffold helpful, consider buying me a coffee! Your support helps maintain and improve the WPZylos ecosystem.

[ ![Donate with PayPal](https://camo.githubusercontent.com/ab874f7381c27789efc0a8502714f480bb5ddcc2de7008417d26b5069068341c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d626c75652e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d70617970616c)](https://www.paypal.com/donate/?hosted_button_id=66U4L3HG4TLCC)---

📄 License
---------

[](#-license)

This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.

---

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

---

**Made with ❤️ by [WPDiggerStudio](https://github.com/WPDiggerStudio)**

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance82

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

2

Last Release

95d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/87be74120ef333e9f794308da1fdcb9505f3e1b255926014a144e6360bb29c08?d=identicon)[WPDiggerStudio](/maintainers/WPDiggerStudio)

---

Top Contributors

[![WPDiggerStudio](https://avatars.githubusercontent.com/u/55980087?v=4)](https://github.com/WPDiggerStudio "WPDiggerStudio (59 commits)")

---

Tags

pluginwordpressdependency-injectionscaffoldtemplatemvcboilerplatePSR-4php-scoperwpzylos

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/wpdiggerstudio-wpzylos-scaffold/health.svg)

```
[![Health](https://phpackages.com/badges/wpdiggerstudio-wpzylos-scaffold/health.svg)](https://phpackages.com/packages/wpdiggerstudio-wpzylos-scaffold)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
