PHPackages                             ashy4n/plugin-template - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ashy4n/plugin-template

ActiveProject[Utility &amp; Helpers](/categories/utility)

ashy4n/plugin-template
======================

A WordPress plugin skeleton (boilerplate) for use with composer create-project.

01PHPCI failing

Since Aug 27Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/Ashy4n/plugin-template)[ Packagist](https://packagist.org/packages/ashy4n/plugin-template)[ RSS](/packages/ashy4n-plugin-template/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Modern WordPress Plugin Boilerplate
===================================

[](#modern-wordpress-plugin-boilerplate)

A comprehensive, modern WordPress plugin boilerplate built with PHP 8+, featuring dependency injection, Twig templating, modern frontend tooling, and best practices for scalable plugin development.

🚀 Features
----------

[](#-features)

### Core Architecture

[](#core-architecture)

- **Object-Oriented Design**: Clean, maintainable architecture using modern PHP 8+ features
- **Dependency Injection**: Full DI container integration with PHP-DI
- **Hookable Interface**: Standardized approach to WordPress hooks with `Hookable` interface
- **PluginData Class**: Centralized plugin information management
- **PHP 8+ Requirement**: Enforces modern PHP features and best practices

### Modern Development Tools

[](#modern-development-tools)

- **Vite + TypeScript**: Modern frontend build system with Hot Module Replacement
- **Sass/SCSS**: Advanced CSS preprocessing with variables and mixins
- **PHPStan**: Static code analysis for PHP
- **PHPUnit**: Comprehensive testing framework
- **PHP CodeSniffer**: Code quality and style enforcement
- **PHP Scoper**: Dependency prefixing to prevent conflicts

### Templating &amp; Frontend

[](#templating--frontend)

- **Twig Templates**: Secure, flexible templating engine
- **React Components**: Modern JavaScript framework for interactive UIs
- **Responsive Design**: Mobile-first CSS architecture
- **Asset Optimization**: Minified and optimized production builds

### Testing &amp; Quality

[](#testing--quality)

- **Unit Tests**: PHPUnit test suite with WordPress function mocking
- **Code Coverage**: Automated test coverage reporting
- **Static Analysis**: PHPStan integration for error detection
- **Code Standards**: PSR-12 and WordPress coding standards

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

[](#-requirements)

- PHP 8.0 or higher
- WordPress 5.0 or higher
- Node.js 16+ (for frontend development)
- Composer (for PHP dependencies)

🛠️ Installation
---------------

[](#️-installation)

### 1. Create a new plugin from this template

[](#1-create-a-new-plugin-from-this-template)

```
composer create-project ashy4n/plugin-template your-plugin-name
cd your-plugin-name
```

### 2. Install dependencies

[](#2-install-dependencies)

```
# Install PHP dependencies
composer install

# Install Node.js dependencies
npm install
```

### 3. Configure your plugin

[](#3-configure-your-plugin)

Run the setup script to configure your plugin:

```
composer run setup
```

This will prompt you for:

- Plugin name
- Plugin slug
- Author name
- Author URI
- Plugin URI
- Description

🏗️ Project Structure
--------------------

[](#️-project-structure)

```
plugin-template/
├── assets-src/                 # Frontend source files
│   ├── components/            # TypeScript/React components
│   ├── styles/               # SCSS files
│   ├── admin.ts              # Admin entry point
│   └── frontend.ts           # Frontend entry point
├── assets/                   # Compiled frontend assets
├── core/                     # Core framework files
├── src/                      # Plugin source code
│   ├── Hooks/               # WordPress hook classes
│   ├── Objects/             # Data objects
│   ├── Services/            # Service classes
│   └── Plugin.php           # Main plugin class
├── templates/               # Twig templates
│   ├── admin/              # Admin templates
│   └── frontend/           # Frontend templates
├── tests/                   # Test files
│   ├── Unit/               # Unit tests
│   └── bootstrap.php       # Test bootstrap
├── lang/                    # Translation files
├── vendor/                  # Composer dependencies
├── node_modules/           # Node.js dependencies
├── composer.json           # PHP dependencies
├── package.json            # Node.js dependencies
├── phpunit.xml            # PHPUnit configuration
├── phpstan.neon           # PHPStan configuration
├── vite.config.ts         # Vite configuration
└── tsconfig.json          # TypeScript configuration

```

🔧 Development Workflow
----------------------

[](#-development-workflow)

### Frontend Development

[](#frontend-development)

```
# Start development server with HMR
npm run dev

# Build for production
npm run build

# Type checking
npm run type-check

# Linting
npm run lint
```

### PHP Development

[](#php-development)

```
# Run tests
composer test

# Run tests with coverage
composer run test:coverage

# Static analysis
composer run analyse

# Code style check
composer run cs

# Fix code style issues
composer run cs:fix
```

### Building for Production

[](#building-for-production)

```
# Build frontend assets
npm run build

# Build PHP with scoped dependencies
composer run build
```

🎯 Key Concepts
--------------

[](#-key-concepts)

### Hookable Interface

[](#hookable-interface)

All classes that interact with WordPress hooks must implement the `Hookable` interface:

```
