millipress / millibase
Declarative WordPress settings framework. Define your settings page in PHP arrays — sections, fields, tabs, validation — and get a React UI automatically.
Requires
- php: >=7.4
Requires (Dev)
- brainmaestro/composer-git-hooks: ^3.0
- pestphp/pest: ^2.0
- php-stubs/wordpress-stubs: ^6.0
- php-stubs/wp-cli-stubs: ^2.12
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: @stable
- szepeviktor/phpstan-wordpress: ^1.3
- wp-coding-standards/wpcs: ^3.0
This package is auto-updated.
Last update: 2026-05-16 19:22:27 UTC
README
Declarative WordPress settings framework. Define your settings page in PHP arrays — tabs, sections, fields, validation — and get a React-powered admin UI automatically.
Requirements
| Requirement | Version |
|---|---|
| PHP | >= 7.4 |
| WordPress | >= 6.0 |
Quick Start
⚠ Plugin authors: prefix MilliBase before shipping. If you bundle MilliBase inside a distributed plugin, you must vendor-prefix it with Strauss or php-scoper. Two plugins shipping the unprefixed
MilliBase\namespace will collide at runtime — only one copy will load, and the other plugin runs against a version it wasn't tested with. See Namespace Prefixing for setup and the rationale behind MilliBase's cross-prefix-tolerant typing.
composer require millipress/millibase
use MilliBase\Manager; $manager = new Manager( slug: 'my-plugin', config: fn() => [ 'page_title' => __( 'My Plugin', 'my-plugin' ), 'menu_title' => __( 'My Plugin', 'my-plugin' ), 'header' => [ 'title' => __( 'My Plugin Settings', 'my-plugin' ) ], 'tabs' => [ [ 'name' => 'general', 'title' => __( 'General', 'my-plugin' ), 'sections' => [ [ 'id' => 'main', 'title' => __( 'Main Settings', 'my-plugin' ), 'fields' => [ [ 'key' => 'general.enabled', 'type' => 'toggle', 'label' => __( 'Enable Feature', 'my-plugin' ), 'default' => true, ], ], ], ], ], ], ], ); // Programmatic access: $manager->settings()->get('general.enabled'); // true
Features
- Declarative schema — define tabs, sections, and fields in PHP arrays
- React admin UI — auto-generated from the schema using
@wordpress/components - 9 built-in field types — text, number, password, toggle, select, unit, token-list, color, code
- Custom extensibility — register custom field types and custom tab components from JS
- Conditional display — show/hide fields based on other settings values
- Settings priority — constants > config file > database > defaults
- Encryption — automatic sodium encryption for sensitive fields (keys prefixed with
enc_) - Config file sync — write settings to PHP files for pre-WordPress access (blog-aware per-operation;
_network-<id>.phpmirror for network-mode) - Network mode —
'network' => trueroutes storage towp_sitemetaand the admin page to Network Admin - Migrations — declarative
name@versionone-shot runner with per-scope state (site / network) - Backup & restore — transient-based backup with 12-hour expiry
- Import / export — settings serialization with encryption handling
- Tab overrides — add-on plugins can extend or replace tabs and sections via filters
- REST API — namespaced
GET/POST /{namespace}/v1/settings+ custom action endpoints - WP-CLI — auto-registered
wp <slug> configcommands; two Managers sharing acli.slugauto-merge into one tree
Documentation
Full documentation is in the docs/ directory:
- Introduction
- Installation
- Configuration
- Schema Definition
- Programmatic Access
- WP-CLI Commands
- Migrations
- Network Settings
- Custom Field Types
- Custom Tab Components
- Extending with Filters
- Reference: Field Types · Settings API · Hooks & Filters · Namespace Prefixing
License
GPL-2.0-or-later