Skip to content

๐ŸšŒ Yo dawg, I heard you like command buses, so I put a command bus in your command bus, so you can command bus whilst you command bus

Notifications You must be signed in to change notification settings

jenkoian/CommandBusCommandBus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CommandBusCommandBus

"Yo dawg, I heard you like command buses, so I put a command bus in your command bus, so you can command bus whilst you command bus"

Installation

composer require jenko/command-bus-command-bus

Usage

Say you have a controller (or whatever) that looks something like

<?php

namespace Acme\Controller;

use Jenko\CommandBusCommandBus\CommandBus

class MyController
{
    /**
     * CommandBus $commandBus
     */
    private $commandBus;

    /**
     * @param CommandBus $commandBus
     */
    public function __construct(CommandBus $commandBus)
    {
        $this->commandBus = $commandBus;
    }

    /**
     * @param Request $request
     */
    public function myAction(Request $request)
    {
        $stuff = $request->get('stuff');
        $command = new MyCommand($stuff);

        $this->commandBus->execute($command);

        //...
    }
}

Then depending on your method of DependencyInjection just inject the required adapter for the command bus you want to use.

For example, in Symfony with controllers as services using Broadway:

services:

    jenko.command_bus.broadway:
        class: Jenko\CommandBusCommandBus\BroadwayCommandBusAdapter
        arguments:
            - @broadway.command_handling.simple_command_bus

    acme.my_controller:
        class: Acme\Controller\MyController
        arguments:
            - @jenko.command_bus.broadway

Disclaimer

This is a silly little project, you're probably better off just using the command bus which best fits your purpose. All the command buses used within this project look great, so pick one of the following, don't use this and I'm sure you won't far go wrong :)

About

๐ŸšŒ Yo dawg, I heard you like command buses, so I put a command bus in your command bus, so you can command bus whilst you command bus

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages