Skip to content

Silex Provider for Command bus and Event bus Features with the SimpleBus/MessageBus

License

Notifications You must be signed in to change notification settings

disasterdrop/silex-simple-bus-provider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Readme

By Sebastian Hübner

This is an Silex Provider for the SimpleBus/MessageBus by Matthias Noback

With this Provider you can register new Events and CommandHandlers within your silex application.

Event Bus

Register Event Bus

$app->register(new \Disasterdrop\SimpleBusProvider\Provider\EventBusProvider());

Add Subscriber to the Event Bus

// Event Bus
$app['eventSubscribers'] = function ($app) {
    $subscribers = [
        SomeEventHappens::class => [
            function ($message) use ($app) {
                $eventSubscriber = new SomeEventHappens($app['someService']);
                return $eventSubscriber->notify($message);
            }
        ]
    ];
    return $subscribers;
};

Command Handler

Register Command Handler

$app->register(new Disasterdrop\SimpleBusProvider\Provider\CommandBusProvider());

Add Handlers to the Command Bus

// Command Bus
$app['commandHandlers'] = function ($app) {
    $handlers = [
        SomeCommand::class => function ($command) use ($app) {
            $commandHandler = new SomeCommandHandler($app['pollWriteRepository'], $app['eventBus']);
            return $commandHandler->handle($command);
        },
    ];
    return $handlers;
};

About

Silex Provider for Command bus and Event bus Features with the SimpleBus/MessageBus

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages