prooph/service-bus-symfony-bundle
Symfony bundle that integrates prooph/service-bus into Symfony apps, with configuration for command, query, and event buses, handler registration, middleware, and dependency injection for building message-driven architectures with minimal boilerplate.
Install the package and publish its config:
composer require prooph/laravel
php artisan vendor:publish --provider="Prooph\Laravel\ProophServiceProvider"
If your app does not use package discovery, register Prooph\Laravel\ProophServiceProvider manually.
Look first at:
config/prooph.php (or equivalent package config),message_detection section,First use case: define a command, handler, and route.
use Prooph\Common\Messaging\HasMessageName;
final class RegisterUser implements HasMessageName
{
public function __construct(public string $email) {}
public function messageName(): string
{
return self::class;
}
}
final class RegisterUserHandler
{
public function __invoke(RegisterUser $command): void
{
// handle command
}
}
Map the command to the handler in the command bus router config, then inject and dispatch Prooph\ServiceBus\CommandBus from a controller/job.
CommandBus, QueryBus, and EventBus so Laravel’s container and package bindings stay consistent.Prooph\Common\Messaging\HasMessageName on commands, queries, and events. In v0.7.0 this is the only requirement for message detection, so you can drop unnecessary marker interfaces.final class ChangeEmail implements HasMessageName
{
private function __construct(public string $email) {}
public static function fromString(string $email): self
{
return new self($email);
}
public function messageName(): string
{
return self::class;
}
}
__invoke handlers remain easier to debug, test, and reason about.async_switch, verify the router config after upgrading. A typical pattern is to route selected messages through an async switch while keeping the rest synchronous:
'router' => [
'type' => \Prooph\ServiceBus\Plugin\Router\AsyncSwitchMessageRouter::class,
'async_switch' => \App\Messaging\AsyncSwitch::class,
'routes' => [
\App\Commands\RegisterUser::class => \App\Handlers\RegisterUserHandler::class,
],
],
HasMessageName is the only requirement, classes that implement it may be auto-detected where you previously relied on another marker. After upgrading, check for unexpected routes or duplicate handler registrations and use explicit include/exclude config if needed.async_switch config mistakes often fail quietly. If the router key or switch class is wrong, messages may fall back to synchronous handling. Test one message that must be async and confirm it is not handled inline.php artisan config:clear when debugging stale behavior.messageName() stable. Changing the returned name can break routing, async queues, and event subscriptions. Prefer the FQCN unless you deliberately version message names.How can I help you explore Laravel packages today?