PHPackages                             zumba/cqrs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. zumba/cqrs

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

zumba/cqrs
==========

CQRS Library

v2.0.0(2y ago)218.0k↓32.4%[2 issues](https://github.com/zumba/cqrs/issues)MITPHPPHP ^8.0

Since Jun 23Pushed 2y ago28 watchersCompare

[ Source](https://github.com/zumba/cqrs)[ Packagist](https://packagist.org/packages/zumba/cqrs)[ Docs](https://tech.zumba.com)[ RSS](/packages/zumba-cqrs/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (6)Used By (0)

Zumba ***CQRS***
================

[](#zumba-cqrs)

[Command Query Responsibility Segregation (*CQRS*)](https://docs.microsoft.com/en-us/azure/architecture/patterns/cqrs)is an established design pattern. This library aims to implement the *plumbing* needed to create CQRS commands and queries.

---

- [Command Bus Usage](#command-bus-usage)
    - [Creating a command](#creating-a-command)
    - [Creating a command handler](#creating-a-command-handler)
    - [Dispatching a command](#dispatching-a-command)
- [Query Bus Usage](#query-bus-usage)
    - [Creating a query handler](#create-a-query-handler)
    - [Dispatching a query](#dispatching-a-query)
- [Providers](#providers)
    - [Class provider](#class-provider)
    - [Method provider](#method-provider)
    - [Simple dependency provider](#simple-dependency-provider)
    - [Create a custom provider](#create-a-custom-provider)
- [Middleware](#middleware)
    - [Logger middleware](#logger-middleware)
    - [Custom middleware](#custom-middleware)

---

Command Bus Usage
-----------------

[](#command-bus-usage)

The command bus allows commands with handlers to be dispatched with the result being either a `Success` or `Failure`.

By design, the command must not return any data.

### Creating a command

[](#creating-a-command)

Creating a command DTO to dispatch to the command bus requires us to extend the abstract `Command` class.

```
