andersonsalas / expressionlab
Expression Lab is a sandboxed diagnostics and data inspection environment for WordPress.
Requires
- php: >=8.4
- maxmind-db/reader: ^1.14
- phpdocumentor/reflection-docblock: ^6.0
- splitbrain/php-archive: ^1.5
- symfony/expression-language: ^7.4
Requires (Dev)
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-18 22:57:47 UTC
README
Expression Lab
A Jupyter-like notebook interface and declarative DSL for WordPress.
Expression Lab is an in-browser, Jupyter-like notebook interface and diagnostics plugin for WordPress. Powered by a declarative Domain-Specific Language (DSL), it lets you inspect posts, options, database tables, caches, HTTP requests, and files-and visualize results with Vega-Lite charts-without writing raw PHP snippets or using eval().
Key capabilities include multi-cell interactive notebooks and a scratchpad mode, visual query and HTTP request builders, in-memory SQLite analytics (Database.mirror()), a filesystem inspector, and encrypted .elab notebook storage (Professional Edition).
Security Pillars
Expression Lab is built around four core security pillars to protect your WordPress environment:
- Declarative AST Sandbox: Expressions are parsed and evaluated through an isolated Abstract Syntax Tree (AST) engine based on Symfony Expression Language, preventing arbitrary PHP code execution.
- Client-Side Cryptography: Authentication uses browser-derived ephemeral Ed25519 keys to sign every request. Master passphrases, private keys, and credentials are never stored in the WordPress database.
- Operational Boundaries: Database operations default to read-only access with in-memory SQLite mirroring, filesystem access enforces path canonicalization, and a CPU watchdog enforces execution time limits.
- Isolated UI & Auditability: The notebook interface runs inside a sandboxed
iframewith anullorigin, and actions are recorded in a built-in audit log.
Note
Expression Lab has not undergone a formal security audit by an independent third-party security firm. For details on the threat model and boundary limits, see the Security Model documentation.
The DSL at a Glance
Fluent Entity Queries
/* Query the latest 5 published posts */ Posts.where('post_type', 'post') .where('post_status', 'publish') .order_by('post_date', 'DESC') .limit(5) .get()
/* Inspect user details and capabilities */ Users.get('anderson')
/* Inspect registered cron schedules */ Options.get('cron')
In-Memory SQLite Analytics
Database.mirror('posts', { 'post_author': 1 }, { 'limit': 100 }) .query(' SELECT (SELECT count(*) FROM wp_posts WHERE post_status = "publish") published, (SELECT count(*) FROM wp_posts WHERE post_status = "draft") drafts, (SELECT count(*) FROM wp_posts WHERE post_status = "trash") trashed ')
Functional Pipeline Operations
prog[ set[ 'posts', Database.mirror('posts', { 'post_status': 'publish' }, { 'limit': 5 }) .query('SELECT ID, post_title, comment_count FROM wp_posts') ], map[ var['posts'], fn[ ['item'], 'Post #' ~ args['item']['ID'] ~ ': "' ~ args['item']['post_title'] ~ '" (' ~ args['item']['comment_count'] ~ ' comments)' ] ] ]
System Requirements
| Component | Requirement | Note |
|---|---|---|
| PHP | 8.4 – 8.5 |
Tested against PHP 8.4 and 8.5 |
| WordPress | 6.4+ |
Tested on modern WordPress releases and Core trunk |
| PHP Extensions | sodium, sqlite3 |
sodium for Ed25519 signature verification; sqlite3 for in-memory database mirroring |
| Environment | Single-site & Multisite | Automated tests run against both configurations |
| Browser | Modern Chromium, Firefox, or Safari | Requires native Web Crypto API and WebAssembly support |
Installation & Setup
1. Installation
Pre-built ZIP Archive - Professional Edition (Recommended)
Pre-built release packages compiled by the repository's CI/CD pipeline are distributed as .zip archives via GitHub Releases. These releases ship Expression Lab Professional Edition (governed by the EULA) with bundled frontend assets and scoped dependencies, installable via Plugins → Add New Plugin → Upload Plugin in WordPress.
From Source - Community Edition (Development)
To build the Community Edition from source:
- Clone the repository into
wp-content/plugins:cd wp-content/plugins git clone https://github.com/andersonsalas/expressionlab.git cd expressionlab
- Install PHP dependencies:
composer install
(For a build without development tooling, usecomposer install --no-dev --optimize-autoloader.) - Install JavaScript dependencies and compile frontend assets:
pnpm install pnpm run build
2. Configuration
- Navigate to Tools → Expression Lab in the WordPress administration dashboard as an administrator.
- Complete the onboarding wizard by defining a master passphrase.
- Append the generated constants to
wp-config.php:
define( 'EXPRESSION_LAB_ADMIN_USER_ID', 1 ); define( 'EXPRESSION_LAB_ADMIN_PUBLIC_KEY', 'your_hex_encoded_public_key' ); define( 'EXPRESSION_LAB_ADMIN_SALT', 'your_unique_salt' );
- Reload the administration interface.
Development & Tooling
# Linting (PHPCS, ESLint, Stylelint) pnpm run lint # Automated Tests pnpm run test:php # PHPUnit (Single-site) pnpm run test:php:ms # PHPUnit (Multisite) pnpm run test:php:all # PHPUnit (Single-site + Multisite) pnpm run test:js # Jest (Frontend) # Frontend Builds pnpm run dev # Development build pnpm run watch # Incremental watch mode pnpm run dev-server # Webpack Encore dev server (HMR) pnpm run build # Production minified bundle
Tip
Frontend Hot Reload: Because the sandboxed iframe blocks localStorage access, disable the iframe sandbox in wp-config.php during local UI development (define( 'EXPRESSION_LAB_SANDBOX_ENABLED', false );) and keep it enabled otherwise.
Documentation (Docusaurus)
pnpm run docs:dev # Start local docs server (English) pnpm run docs:dev:es # Start local docs server (Spanish) pnpm run docs:build # Build static docs pnpm run docs:serve # Preview built docs
Documentation
Full guides and API references are available at docs.expressionlab.io (Español):
- Getting Started: Installation & Configuration · Basic Syntax · Scripting
- API Reference: Database · Options · Cache · Network Sites · Users · Posts · Media · Files · HTTP · Console · IP Lookup · Graph
- Security & Environment: Security Model
Contributing & Security Inquiries
- Contributing: See CONTRIBUTING.md and CODE_OF_CONDUCT.md. Working branches (
fix/*,improve/*,feature/*) targetmastervia Pull Requests and must passpnpm run lintandpnpm run test. - Security Inquiries: Do not report vulnerabilities via public issues. See SECURITY.md or submit reports via GitHub Security Advisories or
github@andersonsalas.com.
License
- Professional Edition: The version distributed via GitHub Releases and compiled by this repository's CI/CD pipeline is proprietary software and is governed by the End-User License Agreement (EULA).
- Community Edition: The standalone base source code hosted in this repository is licensed under the GNU General Public License v2.0 or later (GPL-2.0-or-later).