desmart/laravel-commandbus is a Laravel package for desmart commandbus for laravel.
It currently has 0 GitHub stars and 3.395 downloads on Packagist (latest version 1.1.1).
Install it with composer require desmart/laravel-commandbus.
Discover more Laravel packages by desmart
or browse all Laravel packages to compare alternatives.
Last updated
A small, pluggable command bus.
$ composer require desmart/laravel-commandbusDeSmart\CommandBus\ServiceProvider to app.phpclass RegisterUserCommand
{
protected $email;
public function __construct($email)
{
$this->email = $email;
}
public function getEmail()
{
return $this->email;
}
}
class RegisterUserCommandValidator
{
public function validate(RegisterUserCommand $command)
{
// it will be called before handler
}
}
class RegisterUserCommandHandler
{
public function handle(RegisterUserCommand $command)
{
// it will be called if validator won't throw any exception
}
}
class Controller
{
/**
* @var \DeSmart\CommandBus\Contracts\CommandBus
*/
protected $commandBus;
public function __construct(\DeSmart\CommandBus\Contracts\CommandBus $commandBus)
{
$this->commandBus = $commandBus;
}
public function index()
{
$command = new RegisterUserCommand("[email protected]");
$this->commandBus->handle($command);
}
}