matthis / chief
A simple command bus
Installs: 2 573
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=5.4.0
- illuminate/contracts: 5.*
Requires (Dev)
- phpspec/phpspec: ~2.1
This package is not auto-updated.
Last update: 2025-04-26 20:29:42 UTC
README
A simple Command bus.
Installation
Install via composer.
composer require "matthis/chief:1.2.*"
Usage
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 } }
Tests
vendor/bin/phpspec run