A simple Command bus.
Install via composer.
composer require "matthis/chief:1.2.*"
Executing a command is as simple as:
<?php
$commandBus = new matthis\Chief\CommandBus();
$myCommand = new RegisterUserCommand('John Doe', 'john@doe.com');
$commandBus->execute($myCommand);
Chief expects the following naming convention:
The commands should end with "Command".
Example command:
<?php
class RegisterUserCommand
public function __construct($username, $email)
{
$this->username = $username;
$this->email = $email;
}
}
For Chief to map the command to a command handler the handler should have the same name as the command and have "Handler" appended to it.
Example command handler:
<?php
class RegisterUserCommandHandler
{
public function handle($command)
{
$command->username; //John Doe
$command->email; //john@doe.com
}
}
vendor/bin/phpspec run