Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nuvolapl/cqrs
CQRS abstraction for your application
https://github.com/nuvolapl/cqrs
cqrs php
Last synced: 10 days ago
JSON representation
CQRS abstraction for your application
- Host: GitHub
- URL: https://github.com/nuvolapl/cqrs
- Owner: nuvolapl
- Created: 2019-07-04T10:44:53.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-09T10:10:46.000Z (over 5 years ago)
- Last Synced: 2024-04-18T17:28:47.975Z (7 months ago)
- Topics: cqrs, php
- Language: PHP
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
CQRS [![CircleCI](https://circleci.com/gh/nuvolapl/cqrs/tree/master.svg?style=svg)](https://circleci.com/gh/nuvolapl/cqrs/tree/master)
---
CQRS abstraction for your application# Installation
```bash
composer req nuvolapl/cqrs
```# Usage
```php
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);
}
}
```# Example
- [Basic](/example/public/basic.php) - manual route configuration
- [Magic](/example/public/magic.php) - auto route configuration