General-purpose middleware stack for PHP 7.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.editorconfig
.gitattributes
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
build.xml
composer.json
composer.lock
phpunit.xml

README.md

Rainbow

Latest Version Build Status Software License

Rainbow is a general-purpose middleware stack to wrap before and after logic around any process.

System Requirements

PHP 7.0 or later.

Install

Install using Composer:

$ composer require maximegosselin/rainbow

Rainbow is registered under the MaximeGosselin\Rainbow namespace.

Documentation

For an introduction to the middleware concept, read this.

Declare middleware stack with core process:

$stack = new MiddlewareStack(function($in, $out) {
    // Core process...
});

Push middleware to the stack:

$stack->push(function($in, $out, callable $next) {
    
    /* 'before' logic goes here... */
    
    $out = $next($in, $out);
    
    /* 'after' logic goes here... */
    
    return $out;
});

Call the stack with an inbound value and fetch the outbound value:

$out = $stack->call('foo');

Tests

Run the following command from the project folder.

$ vendor/bin/phpunit

License

The MIT License (MIT). Please see LICENSE for more information.