PHPackages                             optstack/optstack - 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. optstack/optstack

ActiveLibrary[Framework](/categories/framework)

optstack/optstack
=================

WordPress Data Stack Framework - A PHP framework for defining, storing, and managing structured data in WordPress

v0.1.9(2mo ago)010MITPHPPHP &gt;=8.1

Since Jan 29Pushed 2mo agoCompare

[ Source](https://github.com/miketropi/optstack)[ Packagist](https://packagist.org/packages/optstack/optstack)[ RSS](/packages/optstack-optstack/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (12)Used By (0)

OptStack
========

[](#optstack)

> **WordPress Data Stack Framework** — A PHP framework for defining, storing, and managing structured data in WordPress using a unified, extensible stack-based model.

Features
--------

[](#features)

- **Data-first, UI-agnostic** — Focus on data modeling, not UI
- **Native WordPress compatibility** — Works with `get_option()`, `get_post_meta()`, `get_term_meta()`
- **Unified data model** — Same field syntax across Options, Posts, Terms, Users
- **Quick field updates** — Update single fields with automatic searchable field sync
- **Runtime context injection** — Use as plugin or Composer library, no conflicts
- **Composable &amp; extensible** — Interface-driven architecture
- **Future-proof** — Ready for Headless WordPress and REST workflows
- **Modern Admin UI** — React + TypeScript + TailwindCSS frontend

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

[](#requirements)

- PHP 8.1+
- WordPress 6.0+
- Node.js 18+ (for frontend development)

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

[](#installation)

### As a WordPress Plugin

[](#as-a-wordpress-plugin)

1. Clone or download to `wp-content/plugins/optstack/`
2. Run `composer install` in the plugin directory
3. Activate the plugin in WordPress admin

### As a Composer Library (in Themes/Plugins)

[](#as-a-composer-library-in-themesplugins)

OptStack can be used as a pure Composer library in your own plugins or themes:

```
composer require optstack/optstack
```

Then bootstrap with runtime context injection:

```
// In your plugin or theme
require_once __DIR__ . '/vendor/autoload.php';

\OptStack\WordPress\Bootstrap::boot([
    'file' => __FILE__,
    'dir' => plugin_dir_path(__FILE__),  // or get_template_directory() for themes
    'url' => plugin_dir_url(__FILE__),   // or get_template_directory_uri() for themes
    'version' => '1.0.0',
]);
```

**Benefits:**

- ✅ Multiple plugins/themes can use OptStack simultaneously
- ✅ No conflicts between different hosts
- ✅ Assets load from the correct location automatically

See `documents/OPTSTACK_RUNTIME_CONTEXT_INJECTION.md` for details.

### For Frontend Development

[](#for-frontend-development)

```
cd wp-content/plugins/optstack/frontend
npm install
npm run build    # Production build
```

### Development Mode (Hot Reload)

[](#development-mode-hot-reload)

For live reloading during frontend development:

1. Add to `wp-config.php`:

    ```
    define('OPTSTACK_DEV_MODE', true);
    ```
2. Start the dev server:

    ```
    cd wp-content/plugins/optstack/frontend
    npm run dev
    ```
3. Open your WordPress admin page - CSS and component changes update instantly!

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

[](#quick-start)

### Define an Options Stack

[](#define-an-options-stack)

```
use OptStack\OptStack;

// Register on init
add_action('optstack_init', function() {
    OptStack::make('site_settings')
        ->forOptions()
        ->label('Site Settings')
        ->define(function ($stack) {
            $stack->field('site_color', [
                'type' => 'text',
                'label' => 'Primary Color',
                'default' => '#000000',
            ]);

            $stack->group('social', function ($group) {
                $group->field('twitter', ['type' => 'text']);
                $group->field('facebook', ['type' => 'text']);
            });
        });
});

// Access data using native WordPress
$settings = get_option('site_settings');
// ['site_color' => '#000000', 'social' => ['twitter' => '...', 'facebook' => '...']]

// Update a single field (with auto-sync for searchable fields)
OptStack::updateField('site_settings', 'site_color', '#FF5733');
```

### Define a Post Type Stack

[](#define-a-post-type-stack)

```
add_action('optstack_init', function() {
    OptStack::make('product_data')
        ->forPostType('product')
        ->label('Product Data')
        ->define(function ($stack) {
            $stack->group('pricing', function ($group) {
                $group->field('price', ['type' => 'number']);
                $group->field('currency', [
                    'type' => 'select',
                    'options' => ['USD' => 'US Dollar', 'EUR' => 'Euro'],
                ]);
            });
        });
});

// Access via post meta
$product_data = get_post_meta($post_id, 'product_data', true);
```

### Define a Taxonomy Stack

[](#define-a-taxonomy-stack)

```
add_action('optstack_init', function() {
    OptStack::make('category_settings')
        ->forTaxonomy('category')
        ->define(function ($stack) {
            $stack->field('icon', ['type' => 'text']);
            $stack->field('color', ['type' => 'text']);
        });
});
```

Field Types
-----------

[](#field-types)

TypeDescriptionOptions`text`Single-line text input`placeholder``number`Numeric input`min`, `max`, `step``textarea`Multi-line text`rows``select`Dropdown select`options``boolean`Toggle/checkbox—Groups &amp; Repeatables
------------------------

[](#groups--repeatables)

```
$stack->group('features', function ($group) {
    $group->repeatable(1, 10); // min 1, max 10 items

    $group->field('title', ['type' => 'text']);
    $group->field('enabled', ['type' => 'boolean']);
});

// Data structure:
// ['features' => [
//     ['title' => 'Feature A', 'enabled' => true],
//     ['title' => 'Feature B', 'enabled' => false],
// ]]
```

Conditional Fields
------------------

[](#conditional-fields)

```
$stack->field('enable_advanced', ['type' => 'boolean']);

$stack->field('advanced_option', [
    'type' => 'text',
    'conditions' => [
        ['field' => 'enable_advanced', 'operator' => '==', 'value' => true]
    ]
]);
```

REST API
--------

[](#rest-api)

OptStack exposes a REST API for frontend consumption:

- `GET /wp-json/optstack/v1/stacks` — List all stacks
- `GET /wp-json/optstack/v1/stacks/{id}` — Get stack schema
- `GET /wp-json/optstack/v1/stacks/{id}/data` — Get stack data
- `POST /wp-json/optstack/v1/stacks/{id}/data` — Save stack data

Architecture
------------

[](#architecture)

```
┌─────────────────────────────────────────┐
│           Renderers (UI/API)            │  ← React Admin, REST
├─────────────────────────────────────────┤
│         Store Adapters (WP)             │  ← OptionsStore, PostStore
├─────────────────────────────────────────┤
│           Core Framework                │  ← Pure PHP, no WP
└─────────────────────────────────────────┘

```

- **Core** — Pure PHP, no WordPress dependencies, fully unit testable
- **WordPress** — Store adapters and hooks
- **Frontend** — React + TypeScript admin UI

Directory Structure
-------------------

[](#directory-structure)

```
optstack/
├── src/
│   ├── Core/           # Pure PHP framework
│   ├── WordPress/      # WP integration
│   ├── Schema/         # Schema export
│   └── OptStack.php    # Main facade
├── frontend/
│   ├── src/            # React/TypeScript source
│   ├── dist/           # Built assets
│   └── vite.config.ts  # Build configuration
├── examples/           # Usage examples
├── tests/              # PHPUnit tests
└── optstack.php        # Plugin bootstrap

```

Development
-----------

[](#development)

```
# Backend
composer install
composer test

# Frontend
cd frontend
npm install
npm run build    # Production build
npm run dev      # Development server (requires OPTSTACK_DEV_MODE)
```

### Frontend Dev Mode

[](#frontend-dev-mode)

OptStack supports hot module replacement (HMR) for rapid frontend development.

**Setup:**

1. Enable dev mode in `wp-config.php`:

    ```
    define('OPTSTACK_DEV_MODE', true);
    // Optional: custom port
    // define('OPTSTACK_DEV_SERVER', 'http://localhost:3000');
    ```
2. Start Vite dev server:

    ```
    cd frontend && npm run dev
    ```
3. Refresh your WordPress admin page - changes will update live!

**How it works:**

- In dev mode, WordPress loads assets from Vite's dev server (`localhost:5173`)
- CSS changes apply instantly via HMR
- JS/TSX changes trigger a page refresh
- In production mode (default), built assets from `frontend/dist/` are used

License
-------

[](#license)

MIT License

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance86

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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 ~3 days

Total

10

Last Release

79d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0df2b11f8a6270efa8eda4106bb86f426262b6bfec0e2d0edadb43ca779ba641?d=identicon)[mikehuynh](/maintainers/mikehuynh)

---

Top Contributors

[![miketropi](https://avatars.githubusercontent.com/u/82441975?v=4)](https://github.com/miketropi "miketropi (42 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/optstack-optstack/health.svg)

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

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)

PHPackages © 2026

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