PHPackages                             hsm/wplite - 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. [Framework](/categories/framework)
4. /
5. hsm/wplite

ActiveLibrary[Framework](/categories/framework)

hsm/wplite
==========

WPLite WordPress Framework

v1.0.4(5mo ago)1321MITPHP

Since Nov 20Pushed 2mo agoCompare

[ Source](https://github.com/bahmankhah/wplite)[ Packagist](https://packagist.org/packages/hsm/wplite)[ RSS](/packages/hsm-wplite/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (6)Used By (1)

WPLite
======

[](#wplite)

A lightweight, Laravel-inspired micro framework for building WordPress plugins with modern PHP architecture.

WPLite gives you **service containers**, **facades**, **middleware pipelines**, **expressive routing**, **Eloquent-style models**, **views**, **caching**, **auth guards**, and more — without leaving the WordPress ecosystem.

[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP](https://camo.githubusercontent.com/4a5057a857cdb86cf011d334f86b1bbf627728435b1bce61d0859516874ee5f8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344372e342d3838393242462e737667)](https://php.net)

---

Quick Start
-----------

[](#quick-start)

```
composer create-project hsm/wplite-plugin
cd my-plugin
php vendor/hsm/wplite/wplite build --prefix=MyPlugin
```

---

Features
--------

[](#features)

- **Service Container** — Auto-resolving dependency injection via reflection
- **Facades** — Static-like access: `App`, `Route`, `View`, `Cache`, `Auth`, `Config`, `Wordpress`
- **4 Route Types** — REST API, Ajax, Admin pages, and Web routes from one unified router
- **Middleware Pipeline** — Chainable middleware on any route (Laravel-style `$pipeline->next()`)
- **Query Builder &amp; Models** — Fluent `$wpdb` wrapper with `hasMany`, `hasOne`, `belongsTo`, `hasOneMeta` relationships
- **Service Providers** — Lifecycle hooks: `register`, `bootEarly`, `onInit`, `boot`, `admin`, `ajax`, `rest`, `activate`, `deactivate`, `uninstall`
- **View Engine** — PHP-based templating with dot notation (`view('emails.welcome', $data)`)
- **Cache Layer** — Driver-based (ships with WordPress Transients), extensible via Adapter pattern
- **Auth Guards** — Pluggable authentication (ships with SSO/OAuth2 guard)
- **JSON Resources** — API response transformers (`::make()`, `::collection()`)
- **OOP Shortcodes** — Class-based shortcodes with attributes and defaults
- **Namespace Isolation** — Build tool rewrites all namespaces so multiple WPLite plugins never conflict
- **CLI Tool** — `php wplite build` to scaffold and brand the framework
- **`.env` Support** — Environment variables loaded automatically
- **Config System** — Dot-notation access (`appConfig('app.api.namespace')`)
- **Logging** — Built-in file logger

---

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4
- WordPress (any modern version)
- Composer

---

Installation
------------

[](#installation)

### New Project

[](#new-project)

```
composer create-project hsm/wplite-plugin
```

### Add to Existing Plugin

[](#add-to-existing-plugin)

```
composer require hsm/wplite
```

---

Namespace Isolation (Build Step)
--------------------------------

[](#namespace-isolation-build-step)

**This is the critical step.** WPLite rewrites all framework namespaces to your plugin's unique namespace so that **multiple plugins using WPLite coexist on the same WordPress installation without any conflict**.

```
php vendor/hsm/wplite/wplite build --prefix=MyPlugin
```

What this does:

1. Copies the framework source into `src/WPLite/` in your project
2. Rewrites every `namespace WPLite\*` → `namespace MyPlugin\WPLite\*`
3. Rewrites every `use WPLite\*` → `use MyPlugin\WPLite\*`
4. Updates all fully qualified class references and PHPDoc annotations
5. Namespaces helper functions to prevent global collisions
6. Saves your prefix to `wplite-config.json` for future builds

After the first run, subsequent builds only need:

```
php vendor/hsm/wplite/wplite build
```

Use `--dry-run` to preview all changes without writing files.

### CLI Options

[](#cli-options)

```
php vendor/hsm/wplite/wplite build --prefix=MyPlugin        # Build with prefix
php vendor/hsm/wplite/wplite build                           # Use saved prefix
php vendor/hsm/wplite/wplite build --dry-run                 # Preview changes
php vendor/hsm/wplite/wplite build --output=lib/Core         # Custom output dir
php vendor/hsm/wplite/wplite --help                          # Show help
```

---

Bootstrap
---------

[](#bootstrap)

Your main plugin file:

```
