simple-bus/message-bus
Generic PHP interfaces and utilities for building message buses such as command buses and event buses. Provides reusable components to dispatch messages through middleware and handlers, forming the foundation for CQRS-style messaging in your app.
Illuminate\Queue) but offers higher-level abstractions for message routing, validation, and dispatching.bind()).failed_jobs table suffice, or is a custom solution needed?MessageBus, CommandBus) to implementations (e.g., queue-backed bus).Illuminate\Queue as the transport layer for async processing.messages) with status (pending/processed/failed).MessageBus interface for unit tests.actingAs() or fake() for integration tests with queues.// Register bus in a service provider
$this->app->bind(MessageBus::class, function ($app) {
return new QueueMessageBus(
new LaravelQueueAdapter($app['queue']),
new InvocationMiddleware(),
new LoggingMiddleware()
);
});
bus->dispatch(new CreateUserCommand())).Event::dispatch() to bus->dispatch(new EventMessage()).CreateUserCommand, UserCreatedEvent).@TargetQueue('high-priority')).MessageHandler for each message type.messages/ directory).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Queue worker crashes | Messages undelivered | Supervisor (e.g., Laravel Forge/Envoyer) + retries. |
| Handler throws exception | Message lost (unless persisted) | Dead-letter queue + alerting. |
| Database/Redis outage | Message loss (if not persisted) |
How can I help you explore Laravel packages today?