chubbyphp/chubbyphp-lazy-middleware

Chubbyphp Lazy Middleware

1.1.0 2018-05-18 05:43 UTC

README

Build Status Scrutinizer Code Quality Code Coverage Total Downloads Monthly Downloads Latest Stable Version Latest Unstable Version

Description

Allow to lazyload middlewares.

Requirements

  • php: ~7.0
  • psr/container: ~1.0
  • psr/http-message: ~1.0

Installation

Through Composer as chubbyphp/chubbyphp-lazy-middleware.

composer require chubbyphp/chubbyphp-lazy-middleware "~1.1"

Usage

<?php

use Chubbyphp\Lazy\LazyMiddleware;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;

$container['service'] = function (Request $request, Response $response) {
    // run some lazy logic
};

$middleware = new LazyMiddleware($container, 'service');
$response = $middleware($request, $response);

Copyright

Dominik Zogg 2016