Download the PHP package vshf/php-bus without Composer
On this page you can find all versions of the php package vshf/php-bus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-bus
VSHF PHP Command Bus
A lightweight and expressive Command/Query Bus for PHP.
Installation
Usage
Instantiate the Bus instance:
Commands
Dispatching a command:
Each command must have a corresponding handler in the same namespace:
Queries
The bus supports query handlers via :
Query handlers must implement , and the query class must declare its expected result type:
The bus validates the returned type at runtime.
Middleware
Registering a middleware:
The middleware class must implement MiddlewareInterface.
Middleware Priority
Higher values = later execution:
Subscriptions
Handlers can be explicitly registered:
Retrieve them:
Breaking Changes (v2.0)
Version 2.0 introduces several important updates:
1. Middleware now receives the handler result
Old:
New:
All middleware implementations must update their method signature.
2. Full Query Bus Support
A complete query pipeline has been added:
- New method: ask()
- Query subscriptions
- Query handler interfaces
- Result type validation
- Middleware support for queries
Older patterns are not compatible.
3. removed
Replaced by explicit methods:
Changelog
[2.0.0] — 2025-11-20
Major release with breaking changes and new features.
Added
-
Query Bus Support
- New
ask()method. - Introduced
QueryInterfaceandQueryHandlerInterface. - Added query subscriptions via
subscribeQuery(). - Query handlers validated against the expected return type using
getResultType().
- New
-
Middleware Enhancements
- Middleware
after()now receives the handler result. - Middleware is executed for both commands and queries.
- Middleware
- New Introspection Methods
getCommandSubscriptions()getQuerySubscriptions()getMiddlewares()(sorted by priority)
Changed (Breaking)
- Middleware signature change
after()must now be declared as:
Removed
- Implicit query behavior from v1 (no longer compatible).
- Deprecated
getSubscriptions().
Migration Notes
- Update all middleware implementations to the new
after($result = null)signature. - Replace any use of
getSubscriptions()with:getCommandSubscriptions()getQuerySubscriptions()
License
This project is open-sourced software licensed under the MIT license