Download the PHP package bmd/wp-framework without Composer
On this page you can find all versions of the php package bmd/wp-framework. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bmd/wp-framework
More information about bmd/wp-framework
Files in bmd/wp-framework
Package wp-framework
Short Description Generic WordPress framework plugin
License GPL-2.0-or-later
Informations about the package wp-framework
WP Framework
A small Composer library for bootstrapping WordPress plugins and themes with a PHP-DI service container, auto-mounted controllers, context-aware asset loading, and shared path/URL helpers.
The framework is intentionally light: it does not own routing, templating, build tooling, or plugin headers. It gives a package a predictable lifecycle and a few reusable services so feature code can stay in small classes.
Requirements
- PHP 8.1 or newer
- WordPress
- Composer
Installation
Install the package with Composer:
Then load Composer's autoloader from your plugin or theme entrypoint:
Quick Start
Create an application class that extends Bmd\WPFramework\Main, set a package slug, and mount it after WordPress has loaded enough for plugin path and URL helpers to work.
config.package defaults to static::PACKAGE, and the package slug is used to namespace WordPress actions and filters.
Lifecycle
Main::mount() performs the framework boot sequence:
- Registers configuration values in the service container.
- Registers the core controllers.
- Builds the PHP-DI container.
- Mounts any registered service that implements
Bmd\WPFramework\Interfaces\Controller.
Controllers extend Bmd\WPFramework\Abstracts\Controller. When a controller is mounted, its mountActions() and mountFilters() methods are called.
Service Container
Services are registered as PHP-DI definitions. The framework exposes convenience wrappers through Bmd\WPFramework\Services\ServiceLocator, including:
ServiceLocator::autowire()ServiceLocator::create()ServiceLocator::get()ServiceLocator::factory()ServiceLocator::decorate()ServiceLocator::value()ServiceLocator::string()
Add your own services or controllers by extending Main::getServiceDefinitions():
You can retrieve a service after boot with:
Configuration
The default configuration entries are:
config.package: the package slug used for framework hooks.config.dir: the root directory used byFilePathResolver.config.url: the root URL used byUrlResolver.
Configuration is filterable before it is added to the container:
Context Handling
The context provider determines where WordPress currently is and dispatches a chain of context names from most specific to broadest fallback.
Built-in context handlers:
ADMINmaps toBmd\WPFramework\Context\AdminFRONTENDmaps toBmd\WPFramework\Context\FrontendLOGINmaps toBmd\WPFramework\Context\Login
Context chains include:
- Block editor:
EDITOR,ADMIN - Front page:
FRONTPAGE,SINGLE,FRONTEND - Blog home:
BLOG,ARCHIVE,FRONTEND - Search results:
SEARCH,ARCHIVE,FRONTEND - Archive:
ARCHIVE,FRONTEND - Singular content:
SINGLE,FRONTEND - 404:
ERROR404,FRONTEND - Admin:
ADMIN - Login:
LOGIN - Ajax:
AJAX - Cron:
CRON
The first context name that resolves to a registered class implementing Bmd\WPFramework\Interfaces\ContextHandler is mounted through the package context hook.
Built-in handlers enqueue conventional bundles:
build/frontend.jsandbuild/frontend.cssbuild/admin.jsandbuild/admin.cssbuild/login.jsandbuild/login.css
Asset Loading
Context handlers extend Bmd\WPFramework\Abstracts\ContextHandler, which provides:
enqueueScript( $handle, $path, $dependencies = [], $version = '', $in_footer = true )enqueueStyle( $handle, $path, $dependencies = [], $version = null, $screens = 'all' )
Local files are resolved relative to config.dir and converted to URLs relative to config.url. Empty local files are skipped. Remote URLs and protocol-relative URLs are allowed.
For scripts, a sibling WordPress asset file is detected automatically:
When present, the asset file can provide dependencies and a version generated by WordPress build tooling.
Dependency arrays are filterable per handle:
Path And URL Services
The framework registers:
Bmd\WPFramework\Services\FilePathResolverBmd\WPFramework\Services\UrlResolverBmd\WPFramework\Services\ScriptLoaderBmd\WPFramework\Services\StyleLoader
Example usage from an autowired service:
Helpers
Bmd\WPFramework\Helpers includes small utility methods for:
- Class, interface, and trait checks:
classUses(),className(),implements(),uses(),getTraits() - Array handling:
isList(),arrayMerge() - Value normalization:
truthyFalsy() - WordPress plugin checks:
isPluginActive() - String formatting:
slugify(),hyphenate()
Development
Install development dependencies:
Run the test suite:
Run static analysis:
Run PHPCS:
Changelog
0.2.7 - 2026-05-05
- Changed context mounting to dispatch the resolved context handler instance through the package-level mount action.
- Expanded README documentation for installation, bootstrapping, services, contexts, assets, helpers, and development commands.
0.2.6 - 2026-04-30
- Fixed PHP 8.2 deprecation warning from passing null to class_exists() in helper class checks.