Skip to content

Architecture

Lukman Nakib edited this page May 30, 2026 · 1 revision

Architecture

A small Laravel-flavoured core wraps WordPress so you declare features instead of wiring hooks by hand.

Boot flow

  1. wp-plugin-matrix-starter.php defines constants, loads the autoloader, and binds the Lifecycle to activation/deactivation. It also registers the WP-CLI commands under defined('WP_CLI').
  2. On plugins_loaded (and during (de)activation) it boots app/bootstrap.php: constructs the Application (a DI Container), wires the Facades to it, and registers two ServiceProviders.
  3. AppServiceProvider::boot() includes routes.php + hooks.php, sets the Tracer gate, then Router::register() and Hook::register_all_hooks(). On init it emits the Localized Routes (window.wppmRoutes) onto the admin script.
  4. AdminServiceProvider::boot() instantiates each AdminPage, registers it (admin_menu), and emits window.wppmListPages for ListPages.

Visual map: open docs/architecture-graph.html from the source tree.

The modules

Module Responsibility
Core/Application + Container DI container; resolve services anywhere via wp_plugin_matrix_app('x').
Core/Router Single seam for REST + AJAX routes; nonce/method/capability enforcement.
Core/Hook Registry for WP add_action/add_filter.
Core/AdminPage / ListPage Declarative admin screens; ListPage adds Model-backed CRUD + 5 auto REST routes.
Model/BaseModel Thin wpdb ORM: fill/validate/save/paginate with $rules/$fillable/$sortable.
Core/Lifecycle + Database/Migrations/Migrator Activation/uninstall orchestration + versioned migrations.
Core/Tracer Gated recorder that decorates the Hook/Router callables into a per-request trace.
Facades/ (Asset/Cache/Config) Static entry points to deep services.
Helpers/ SettingsPage, Notice, CPT, Cron.

Vocabulary

The project keeps a deliberate vocabulary (see CONTEXT.md): AdminPage, ListPage, Route (REST/AJAX), Rules, Localized Routes, Notice, Hook, Lifecycle, Migration, Migrator, Tracer, Generator, Personalizer. Use these terms when naming your own modules.

Contracts (don't break casually)

Route names, the wppm/* hook/filter names, the wp-plugin-matrix/v1 REST namespace, the wp_plugin_matrix nonce action, and the wppmRoutes/wppmListPages localized-object shapes are consumed by downstream code and the JS layer. Treat them as a public API.

Clone this wiki locally