2017 © Pedro Peláez
 

library core

container-interop aware command-bus

image

commander/core

container-interop aware command-bus

  • Friday, December 9, 2016
  • by geggleto
  • Repository
  • 2 Watchers
  • 1 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Commander

Micro-Service Command/Event Framework, (*1)

Commander maps a HTTP Request to a Command Handler and listens for Framework Events., (*2)

How to use

1) Write a Command Handler - Make sure to Fire CompletedEvent - Make sure to Fire ErrorEvent, (*3)

2) Tell commander what end-point the handler is for, (*4)

3) Do something with your Event, (*5)

Use Cases

Currently we only support JSON APIs., (*6)

Simple Example

$commander = new Commander();
$this->commander->get('/user/{id}', 'user.cache.get', SimpleGetUserHandler::class);
$commander->run();


//In SimpleGetUserHandler
class SimpleGetUserHandler extends Handler
{
    /**
     * @param CommandInterface $command
     */
    public function handle(CommandInterface $command)
    {
        $this->eventBus->notify(CompletedEvent::makeEvent(['id' => '1'])); //fill in the user info
    }
}

Why ??

  • CQRS!
  • Less Boilerplate.
  • Greater Testability.
  • No Controllers or Controller Actions...
  • Better Resource Usage

Framework Events

You can subscribe to the following Framework Events, (*7)

  • Framework.Complete, (*8)

    • This event is raised when the response has been completed
    • Payload: User Defined
  • Framework.Error, (*9)

    • This event is raised if there has been an error somewhere
    • Payload: User Defined or Framework Errors are ["message" => "..."]
  • Framework.CommandBus.Handle, (*10)

    • This event is fired when a Command Handler is about to be executed
    • Payload: [CommandKey]
  • Framework.Invoke, (*11)

    • This event is fired when a Command is about to be fired to the command bus
    • Payload: ["commandKey" => "", "commandClass" => ""]
  • Framework.EventBus.Notify, (*12)

    • This event is fired when an Event is about to be sent to the EventBus.
    • Will not propagate Framework.EventBus.Notify's
    • Payload: callable... [$object, "method"]

Todo

  • Event Payloads
    • JsonPayload
    • TextPayload
    • XMLPayload

Contributors

The Versions

09/12 2016

dev-master

9999999-dev

container-interop aware command-bus

  Sources   Download

MIT

The Requires

 

The Development Requires

by Glenn Eggeton

01/12 2016

1.0.0

1.0.0.0

container-interop aware command-bus

  Sources   Download

MIT

The Requires

 

The Development Requires

by Glenn Eggeton