composepress / starter
A clean-slate starter plugin for building WordPress plugins on ComposePress
Requires
- composepress/core: ^0.3.0
- composepress/settings: ^0.1.0
- level-2/dice: dev-v2.0-PHP5.4-5.5
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-09-16 12:27:53 UTC
README
A clean-slate starter plugin for building WordPress plugins on
ComposePress. The core exposes an
explicit composition API (Plugin, PluginContext, HookSubscriber, Hooks,
WordPressHooks, PluginLifecycle, PluginUninstall) with no container, no
settings, and no UI layer. This starter shows how a real plugin wires those
contracts together.
Requirements
- PHP 8.2 or newer
- Composer 2
- WordPress 6.4 or newer
Setup
Clone this repository and install dependencies:
composer install
Dependency note. The core is not yet tagged or published to Packagist, so this package resolves it from the
ComposePress/corerepository through a Composer VCS repository. Once a tagged release is published, replace the"composepress/core": "dev-master"requirement with the published constraint (for example^1.0).
Activate the plugin from Plugins → Installed Plugins. The plugin head is
composepress-starter.php; its Plugin header block and the VERSION/SLUG
constants in src/StarterPlugin.php must change if you rename it.
Structure
composepress-starter.php Plugin header, autoload guard, and boot call
src/
StarterPlugin.php Composition root: builds and boots the core Plugin
ExampleSubscriber.php A HookSubscriber demonstrating hook registration
StarterActivator.php Activation behaviour, single-site and network-wide
StarterDeactivator.php Deactivation behaviour, single-site and network-wide
Uninstall.php Static uninstall behaviour
tests/ PHPUnit tests; boundaries use core Testing doubles
phpunit.xml.dist PHPUnit configuration
phpstan.neon PHPStan configuration (level 8)
.phpcs.xml.dist PHPCS configuration (PSR-12)
How it boots
composepress-starter.php guards against a missing vendor/ directory,
loads Composer's autoloader, then calls StarterPlugin::boot(__FILE__)
immediately during plugin-file inclusion. Booting at include time is required so
WordPress registers the activation, deactivation, and uninstall hooks before it
finishes loading the plugin. StarterPlugin constructs every collaborator
explicitly and hands them to the core Plugin; subscribers only register their
callbacks, and their work runs when WordPress fires the hooks.
Extension points
- Add a subscriber. Implement
ComposePress\Core\HookSubscriber(register actions/filters through theHooksargument) and register an instance in the subscribers array insideStarterPlugin::boot(). Keep business logic in plain methods on the subscriber so it stays testable without WordPress. - Add lifecycle work. Implement
ComposePress\Core\PluginActivatorand/orComposePress\Core\PluginDeactivatorwith real work (schema, options, cron) and pass instances toPlugin. - Add uninstall work. Implement
ComposePress\Core\PluginUninstall::uninstall()as astaticmethod and pass the class string toPlugin. - Add a dependency. Construct it and inject it in
StarterPlugin::boot()rather than locating services at runtime.
Verification
composer lint # PHP syntax check composer test # PHPUnit unit tests (WordPress functions are shimmed) composer analyse # PHPStan level 8 composer style # PHPCS PSR-12
License
GPL-3.0-or-later. See LICENSE.