A modular framework for WordPress plugins that read as hand-written WordPress code: five packages, each building only on the one below it, with each plugin shipping its own scoped copy.
Monorepo publishing five Composer packages:
| Package | Purpose |
|---|---|
ahegyes/wp-framework-bootstrap |
The code a WordPress plugin runs before its autoloader. It parses on PHP 7.4, so a site below the plugin's floors gets a notice instead of a fatal error and still receives the release that fixes it. |
ahegyes/wp-framework-shared |
The WordPress-free building blocks every framework package shares, kept portable enough to work unchanged in any PHP project. |
ahegyes/wp-framework-core |
The plugin kernel. A plugin is composed of small components that load only where they apply, on WordPress's own APIs, with the infrastructure WordPress leaves every plugin to rebuild. |
ahegyes/wp-framework-settings |
Settings screens and edit-screen fields declared as data, so WordPress's own APIs render, validate and save them and a plugin never hand-writes form handling. |
ahegyes/wp-framework-woocommerce |
The framework's settings, edit-screen and logging helpers carried onto WooCommerce's own screens and APIs, for plugins that extend WooCommerce. |
The packages form a stack: core builds on bootstrap and shared, settings on core, and woocommerce on settings, and shared also installs alone. Each package's README covers installing, prefixing and using it.
- PHP: the floor
composer.jsondeclares underrequire.php; each package'scomposer.jsondeclares its own, the bootstrap package's lower - WordPress: the highest floor the package manifests declare under
extra.requires-wp - Node.js and npm: the versions
package.jsondeclares underengines(for wp-env CLI) - Docker: for the wp-env environments
npm run setup # PHP and Node deps, then the developer environment at http://localhost:8800, as local, with WooCommerce
composer quality-check # Validation, PHPCS, PHPStan, Unit and Integration tests (starts the tests environment)- Unit tests (
tests/Unit/) run in plain PHP with no WordPress loaded. - Integration tests (
tests/Integration/) run inside wp-env'sclicontainer against real WordPress, hooks and users, on a single site with WooCommerce, and themultisiteandwithout-woocommercegroups on a network without it.test:integrationstarts the tests environment before every run, which also applies any change to its config;test:integration:runskips that start, as CI does after starting the environment itself. - Fixture plugins (
tests/Fixtures/consumer-a/,tests/Fixtures/consumer-b/): consumer-a is a WooCommerce plugin built on all five packages, and consumer-b one built on every package but woocommerce. Each installs them through its owncomposer.json, scopes them with wordpress-configs and passes PHPStan on its own code, and the Integration tests run its production build through wp-admin requests and WP-CLI. - Personas (
tests/Fixtures/personas/): one per stack, each requiring only the top package of its stack and built like the fixture plugins, so each production build holds exactly its scoped closure and nothing unscoped. - Prefer-lowest lane (
tests/bin/prefer-lowest.sh): consumer-a runs with its runtime packages locked at the lowest versions its constraints allow, so a minimum too low to work fails before a consumer installs it. The core, settings and woocommerce personas join it once the mirrors carry release tags, since it locks their other framework packages at the lowest allowed tag. - CI runs the Integration tests and the end-to-end spec once for the newest release of every WordPress branch from the floor up, read from WordPress's version API, so a new release joins without a change here; WordPress trunk and WooCommerce's trunk build run nightly, outside pull requests.
- Object cache lanes (
.wp-env.redis.json,.wp-env.sqlite.json): the single-site Integration tests run again behind the Redis Object Cache plugin's drop-in, on a Redis server itsafterStartscript starts beside the environment, and behind the SQLite Object Cache plugin's, so the framework meets persistent object caches' serialization, lifetimes and failures. - PHP 7.4 tests (
tests/Php74/) run with the host's PHP against a PHP 7.4 site with WordPress 6.3, through WP-CLI in its environment, so bootstrap's code runs where a site sits below every other package's floors. - End-to-end tests (
tests/EndToEnd/) run in Chromium through Playwright on the tests environment, with thetests/Fixtures/end-to-end/plugin active, so each of the framework's inline scripts runs in a browser. - Type tests (
tests/PHPStan/) are files PHPStan analyzes duringlint:php:assertType()calls pin inferred types, and each expected error carries a@phpstan-ignorenaming its identifier, so the run fails when the error disappears.