2017 © Pedro Peláez
 

library middleware

TInfrastructure for use middleware in applications

image

gpslab/middleware

TInfrastructure for use middleware in applications

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Latest Stable Version Total Downloads Build Status Coverage Status Scrutinizer Code Quality SensioLabs Insight StyleCI License, (*1)

Infrastructure for use middleware in applications

Request delegate pipeline, (*2)

Installation

Pretty simple with Composer, run:, (*3)

composer require gpslab/middleware

Middleware chain

MiddlewareChain contains a middlewares (Middleware) and sequentially apply them to the message by chain., (*4)

There are 3 implementations of the chain, but you can make your own., (*5)

  • DirectBindingMiddlewareChain - direct binding;
  • ContainerMiddlewareChain - PSR-11 container;
  • SymfonyContainerMiddlewareChain - Symfony container (Symfony 3.3 implements a PSR-11).

Handle command (CQRS)

Example usage middleware for handle Commands in CQRS., (*6)

// middleware chain
$chain = new DirectBindingMiddlewareChain();

// add logger middleware
$chain->append(new LoggerMiddleware($logger));
// add validator middleware
$chain->append(new ValidatorMiddleware($validator));
// add middleware for handle command from origin command bus
$chain->append(new CommandMiddleware($command_bus));

// configure command bus
$bus = new MiddlewareCommandBus($chain);


// handle command
try {
    $bus->handle($my_command);
} catch(InvalidMessageException $e) {
    // show validation errors
    var_dump($e->getMessages());
}

Handle query (CQRS)

Example usage middleware for handle Queries in CQRS., (*7)

// middleware chain
$chain = new DirectBindingMiddlewareChain();

// add logger middleware
$chain->append(new LoggerMiddleware($logger));
// add validator middleware
$chain->append(new ValidatorMiddleware($validator));
// add middleware for handle query from origin query bus
$chain->append(new QueryMiddleware($query_bus));

// configure query bus
$bus = new MiddlewareQueryBus($chain);


// handle query
try {
    $bus->handle($my_query);
} catch (InvalidMessageException $e) {
    // show validation errors
    var_dump($e->getMessages());
}

Handle Domain event

Example usage middleware for handle domain events., (*8)

// middleware chain
$chain = new DirectBindingMiddlewareChain();

// add logger middleware
$chain->append(new LoggerMiddleware($logger));
// add middleware for handle event from origin domain event bus
$chain->append(new DomainEventMiddleware($domain_event_bus));

// configure domain event bus
$bus = new MiddlewareDomainEventBus($chain);


// publish domain event
$bus->publish($my_event);

License

This bundle is under the MIT license. See the complete license in the file: LICENSE, (*9)

The Versions

17/07 2017
17/07 2017
13/07 2017

1.0.x-dev

1.0.9999999.9999999-dev https://github.com/gpslab/middleware

TInfrastructure for use middleware in applications

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

middleware psr-3 symfony cqrs infrastructure psr-11

23/06 2017