PHPackages                             php-commons/cqrs-bus - 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. [Framework](/categories/framework)
4. /
5. php-commons/cqrs-bus

ActiveSymfony-bundle[Framework](/categories/framework)

php-commons/cqrs-bus
====================

CQRS Bus is Symfony 4.3+ Bundle with Command Bus &amp; QueryBus using Symfony Messanger

1.0.0(6y ago)080[3 PRs](https://github.com/phpCommons/cqrs-bus/pulls)MITPHP

Since Nov 5Pushed 6y ago1 watchersCompare

[ Source](https://github.com/phpCommons/cqrs-bus)[ Packagist](https://packagist.org/packages/php-commons/cqrs-bus)[ RSS](/packages/php-commons-cqrs-bus/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (5)Used By (0)

cqrs-bus
========

[](#cqrs-bus)

CQRS Bus is Symfony 4.3+ Bundle with Command Bus &amp; QueryBus using Symfony Messanger

Installation
------------

[](#installation)

```
composer require php-commons/cqrs-bus
```

Configuration
-------------

[](#configuration)

`config/services.yaml`

### CommandBus

[](#commandbus)

#### Handler's configuration

[](#handlers-configuration)

```
services:
    App\CommandHandler\MyOwnCommandHandler:
        autoconfigure: false
        tags:
            - { name: messenger.message_handler, bus: command.bus }
    ...
    App\CommandHandler\MyCustomCommandHandler:
        autoconfigure: false
        tags:
            - { name: messenger.message_handler, bus: command.bus }
    ...
```

or

```
command_handlers:
    namespace: App\CommandHandler\
    resource: '%kernel.project_dir%/src/CommandHandler/*CommandHandler.php'
    autoconfigure: false
    tags:
        - { name: messenger.message_handler, bus: command.bus }
```

It's **VERY** important to tag ALL of yours Commands Handlers with: `{ name: messenger.message_handler, bus: command.bus }`, otherwise other MessageHandler can handle query. It's **VERY** important to extend ALL of yours Commands Handlers from: `PhpCommons\CQRSBus\Handlers\Command\AbstractCommandHandler`, otherwise CommandHandler will not find it.

### QueryBus

[](#querybus)

#### Handler's configuration

[](#handlers-configuration-1)

You need to configure your handler in /config/services.yml

```
    App\Query\MyOwnQueryHandler:
        autoconfigure: false
        tags:
            - { name: messenger.message_handler, bus: query.bus }
```

or

```
query_handlers:
    namespace: App\MessageHandler\
    resource: '%kernel.project_dir%/src/MessageHandler/*QueryHandler.php'
    autoconfigure: false
    tags:
        - { name: messenger.message_handler, bus: query.bus }
```

It's **VERY** important to tag ALL of yours Queries Handlers with: `{ name: messenger.message_handler, bus: query.bus }`, otherwise other MessageHandler can handle query. It's **VERY** important to extend ALL of yours Queries Handlers from: `PhpCommons\CQRSBus\Handlers\Query\AbstractQueryHandler`, otherwise QueryHandler will not find it.

Usage
-----

[](#usage)

### CommandBus

[](#commandbus-1)

```
