mmalessa/command-bus-bundle

Simple library to implement command-bus.

v1.2 2019-09-01 11:18 UTC

This package is auto-updated.

Last update: 2024-05-29 04:40:57 UTC


README

Requires Symfony 4.3.*
https://github.com/mmalessa/command-bus-bundle
Use it at your own risk.

Install

composer req mmalessa/command-bus-bundle

Example of use

Register your handler(s)

services:
    App\Application\CommandBus\TestCommandHandler:
        tags:
            - { name: mmalessa.command_handler }

The command class is automatically detected based on the type of parameter in the handler 'handle' method.

Create command and handler

(See - README for the mmalessa/command-bus package.)

Inject command bus into Symfony command/controller

use Mmalessa/CommandBus/CommandBus
public function __construct(CommandBus $commandBus)
// [...]

Handle command

$command = TestCommand::create(1, 'Silifon');
$this->commandBus->handle($command);