The contract that all commands must implement to be processed by the command bus.
CommandInterface marker interface for Commands.
interface CommandInterface {}Commands serve as:
- Data Transfer Objects - Carry data needed for a specific operation
- Intent Declaration - Clearly express what operation should be performed
use Webware\CommandBus\CommandInterface;
final readonly class CreateUserCommand implements CommandInterface
{
public function __construct(
public string $email,
public string $username,
public ?string $displayName = null,
public array $roles = ['user']
) {}
}- CommandHandlerInterface - Handlers that process commands
- CommandBusInterface - Bus that dispatches commands
- MiddlewareInterface - Middleware that can intercept commands