Installation
Welcome to CQBus Mediator! 🚀
If you are tired of massive, unmaintainable controllers and tangled business logic in your Laravel applications, you are in the right place. This package brings the power of the CQRS (Command/Query Responsibility Segregation) pattern to your app with zero friction, utilizing modern PHP 8 Attributes.
Requirements
Before you start, ensure your environment meets the following:
- PHP: 8.2 or higher
- Laravel: 11.0, 12.0, or 13.0
Installing via Composer
Pull the package into your project using Composer. Laravel's package discovery will handle the rest automatically.
composer require ignaciocastro0713/cqbus-mediatorConfiguration (Optional)
Out of the box, CQBus Mediator is ready to go. However, if you want to tweak its behavior—like defining custom directories for your handlers or registering global pipelines—you should publish the configuration file:
php artisan vendor:publish --tag=mediator-config🏗️ Using Domain-Driven Design (DDD)?
By default, the package scans your app/ directory for Handlers and Actions. If you use a custom architecture (e.g., a src/Domain/ folder), simply update the handler_paths array in the published config/mediator.php file to point to your custom directories.
What's New in v7.0
- Semantic CQRS attributes —
#[CommandHandler]and#[QueryHandler]as expressive aliases for#[RequestHandler]. PublishResultstyped API —publish()now returns a typed object instead of a plain array, with methods likeget(),handlerClasses(), andisEmpty().- Better error messages —
InvalidRequestClassExceptionnow names the offending attribute; newInvalidPipelineExceptionvalidates pipelines at boot time. - Pipeline cache fix — Zero-reflection dispatch in production is now guaranteed. Regenerate your cache after upgrading.
mediator:listimprovements — Shows the effective pipeline stack per handler in a new Pipelines column.
See the Upgrade Guide for migration steps.