PHP code example of zobzn / psr7-stack

1. Go to this page and download the library: Download zobzn/psr7-stack 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/ */

    

zobzn / psr7-stack example snippets


use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

 ResponseInterface $response, callable $next = null) {
    // do something with request and/or response
    return $next ? $next($request, $response) : $response;
});
$stack->push(function (ServerRequestInterface $request, ResponseInterface $response, callable $next = null) {
    // do something else with request and/or response
    return $next ? $next($request, $response) : $response;
});

$request  = new SomeServerRequestImplementation();
$response = new SomeResponseImplementation();

// execute middlewares on given request and response, and get final response
$response = $stack->__invoke($request, $response);