2017 © Pedro Peláez
 

library cqrs

CQRS library

image

pauci/cqrs

CQRS library

  • Tuesday, June 19, 2018
  • by pauci
  • Repository
  • 2 Watchers
  • 14 Stars
  • 4,168 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 25 Versions
  • 4 % Grown

The README.md

CQRS library

Source Code ![Latest Version][badge-release] Software License ![Build Status][badge-build] [Coverage Status][coverage] ![Total Downloads][badge-downloads], (*1)

Installation & Requirements

The core library has no dependencies on other libraries. Plugins have dependencies on their specific libraries., (*2)

Install with composer:, (*3)

composer require pauci/cqrs dev-master

Usage


class User extends CQRS\Domain\Model\AbstractAggregateRoot { private $name; public function changeName($name) { $oldName = $this->name; $this->name = $name; $this->registerEvent(new UserNameChanged(['name' => $name, 'oldName' => $name])); } } class ChangeUserName extends CQRS\Domain\Payload\AbstractCommand { public $id; public $name; } class UserNameChanged extends CQRS\Domain\Payload\AbstractEvent { public $id; public $name; public $oldName; } class UserService { protected $repository; public function __construct($repository) { $this->repository = $repository; } public function changeUserName(ChangeUserName $command) { $user = $this->repository->find($command->id); $user->changeName($command->name); } } class EchoEventListener { public function onUserNameChanged(UserNameChanged $event) { echo "Name of user #{$event->id} changed from {$event->oldName} to {$event->name}.\n"; } } $command = new ChangeUserName([ 'id' => 1, 'name' => 'Jozko Mrkvicka', ]); $commandBus->dispatch($command);

The Versions

19/06 2018