X Tutup
Skip to content

bauhausphp/message-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage

Stable Version Downloads PHP Version License

Message Bus

Installing

$ composer require bauhaus/message-bus

Getting Started

<?php

use Bauhaus\MessageBus;
use Bauhaus\MessageBusSettings;

class YourCommand {}
class YourCommandHandler
{
    public function __invoke(CommandA $command): void {}
}

class YourQuery {}
class YourQueryResult {}
class YourQueryHandler
{
    public function __invoke(YourQuery $query): YourQueryResult
    {
        return new YourQueryResult();
    }
}

$messageBus = MessageBus::build(
    MessageBusSettings::new()
        ->withPsrContainer(/* Pass here your favorite PSR container */)
        ->withHandlers(
            YourCommandAHandler::class,
            YourQueryHandler::class,
        );
);

$result = $messageBus->dispatch(new YourCommand());
is_null($result); // true

$result = $messageBus->dispatch(new YourCommand());
$result instanceof YourQueryResult; // true

Contributing

Open an issue: https://github.com/bauhausphp/message-bus/issues Code: https://github.com/bauhausphp/contributor-tool

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

X Tutup