2017 © Pedro Peláez
 

library commander

Simple command bus.

image

weew/commander

Simple command bus.

  • Saturday, December 3, 2016
  • by weew
  • Repository
  • 1 Watchers
  • 1 Stars
  • 163 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

Simple command bus

Build Status Code Quality Test Coverage Version Licence, (*1)

Table of contents

Installation

composer require weew/commander, (*2)

Introduction

Commander is a simple message bus. It allows you to register command handlers and to dispatch commands. The main reason to use such an abstraction is to decouple components and dependencies. The caller never knows who will handle a command after all. All he knows is a set of contracts that both sides have to fulfill., (*3)

Commands

A command has no restrictions. You can use almost everything as a command. It is recommended to create simple transfer/value objects and use them as commands. A command is basically a contract between the caller and the handler., (*4)

Registering command handlers

To be able to dispatch commands to handlers, commander has to know who is responsible for each command. That is why you have have to register a handler for each command. A handler can be a callable or a class / instance that implements method handle($command)., (*5)

First let's create a very basic command, a handler and a result., (*6)

class FooCommandHandler {
    public function handle($command) {
        return new FooResult();
    }
}

class FooCommand {
    public function __construct($foo, $bar) {}
}
class FooResult {}

Now comes the command registration., (*7)

$commander = new Commander();
$commander->register(FooCommand::class, FooCommandHandler::class);

Dispatching commands

After you have registered your commands and handlers you can invoke them from anywhere within you application., (*8)

$result = $commander->dispatch(new FooCommand('foo', 'bar'));

Existing container integrations

There is an integration available for the weew/container container. See weew/commander-container-aware., (*9)

The Versions

03/12 2016

dev-master

9999999-dev

Simple command bus.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxim Kott

21/07 2016

v2.2.1

2.2.1.0

Simple command bus.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxim Kott

16/03 2016

v2.2.0

2.2.0.0

Simple command bus.

  Sources   Download

MIT

The Requires

  • weew/php-helpers-string ^1.0.0
  • weew/php-helpers-array ^1.0

 

The Development Requires

by Maxim Kott

03/03 2016

v2.1.0

2.1.0.0

Simple command bus.

  Sources   Download

MIT

The Requires

  • weew/php-helpers-string ^1.0.0
  • weew/php-helpers-array ^1.0

 

The Development Requires

by Maxim Kott

03/03 2016

v2.0.0

2.0.0.0

Simple command bus.

  Sources   Download

MIT

The Requires

  • weew/php-helpers-string ^1.0.0
  • weew/php-helpers-array ^1.0

 

The Development Requires

by Maxim Kott

18/11 2015

v1.2.0

1.2.0.0

Simple command bus.

  Sources   Download

MIT

The Requires

  • weew/php-helpers-string ^1.0.0
  • weew/php-helpers-array ^1.0

 

The Development Requires

by Maxim Kott

18/11 2015

v1.1.0

1.1.0.0

Simple command bus.

  Sources   Download

MIT

The Requires

  • weew/php-helpers-string ^1.0.0

 

The Development Requires

by Maxim Kott

16/11 2015

v1.0.0

1.0.0.0

Simple command bus.

  Sources   Download

MIT

The Requires

  • weew/php-foundation ^1.0.0
  • weew/php-helpers-string ^1.0.0

 

The Development Requires

by Maxim Kott

11/11 2015

v0.0.3

0.0.3.0

Simple command bus.

  Sources   Download

MIT

The Requires

  • weew/php-foundation 0.*
  • weew/php-helpers-string 0.*

 

The Development Requires

by Maxim Kott

11/11 2015

v0.0.2

0.0.2.0

Simple command bus.

  Sources   Download

MIT

The Requires

  • weew/php-foundation ^0.0.9
  • weew/php-helpers-string ^0.0.10

 

The Development Requires

by Maxim Kott

11/11 2015

v0.0.1

0.0.1.0

Simple command bus.

  Sources   Download

MIT

The Requires

  • weew/php-foundation ^0.0.9
  • weew/php-helpers-string ^0.0.10

 

The Development Requires

by Maxim Kott