nuvolapl / cqrs
CQRS
Installs: 60
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/nuvolapl/cqrs
Requires
- php: ^7.3
Requires (Dev)
- phpunit/phpunit: ^8.2
This package is auto-updated.
Last update: 2025-09-28 00:13:31 UTC
README
CQRS abstraction for your application
Installation
composer req nuvolapl/cqrs
Usage
class AccountController { /** * @var SystemInterface */ private $system; public function __construct(SystemInterface $system) { $this->system = $system; } public function post(array $payload): void { $command = new CreateAccountCommand( $payload['name'], $payload['confirmed'], new \DateTimeImmutable() ); $this->system->command($command); } public function get(int $id): Account { return $this->system->query( new GetAccountByIdQuery($id) ); } /** * {@inheritdoc} * * @return Account[] */ public function getCollection(array $query): array { $collection = $this->system->query( new GetAccountCollectionQuery( $query['limit'], $query['offset'] ) ); return \iterator_to_array($collection); } }