PHP code example of ellipse / middleware-callable

1. Go to this page and download the library: Download ellipse/middleware-callable library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ellipse / middleware-callable example snippets




namespace App;

use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;

use Ellipse\Middleware\CallableMiddleware;

// This middleware is wrapped around the given callable.
$middleware = new CallableMiddleware(function (ServerRequestInterface $request, RequestHandlerInterface $handler) {

    // ...

    return $handler->handle($request);

});

// The middleware ->process() method proxy the callable.
$response = $middleware->process($request, $handler);