jralph/server-middleware

A middleware dispatcher supporting psr15.

1.0.0 2018-09-27 16:06 UTC

This package is auto-updated.

Last update: 2024-12-08 10:46:17 UTC


README

Build Status Coverage Status Mutation testing badge

SensioLabsInsight

A PSR-15 compliant server middleware dispatcher implementation.

Goal

The goal of this package is to implement the (currently in draft) PSR-15 spec for middleware in as simple a way as possible.

The entire package MUST be covered by tests.

Usage

See PSR-15 spec for more detailed info on implementing middleware.

<?php

use JRalph\ServerMiddleware\Dispatcher;

$dispatcher = (new Dispatcher())
    ->addMiddleware(
        
          /**
           * Implementations of Psr\Http\Server\MiddlewareInterface
           */
          
          $firstMiddleware,
          $secondMiddleware,
          $thirdMiddleware
          
    );

/** @var \Psr\Http\Message\ServerRequestInterface $request */
$request = new Request;

$response = $dispatcher->handle($request);