PHP code example of amazing79 / middleware-stack

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

    

amazing79 / middleware-stack example snippets


use Amazing79\Middleware\Middleware\BeforeExampleMiddleware;
use Amazing79\Middleware\MiddlewareStack;
use Amazing79\Middleware\Middleware\AfterExampleMiddleware;
use Amazing79\Middleware\Handler\ExampleMainHandler;
use GuzzleHttp\Psr7\ServerRequest;

$stack = new MiddlewareStack(new ExampleMainHandler());
$stack->add(new AfterExampleMiddleware());
$stack->add(new BeforeExampleMiddleware());
$request = new ServerRequest('GET', '/');
$response = $stack->handle($request);
echo (string) $response->getBody();