PHP code example of fastd / middleware

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

    

fastd / middleware example snippets


$middleware = new Middleware(function (RequestInterface $request, DelegateInterface $next) {
    // delegate control to next middleware
    return $next($request);
});

$middleware2 = new Middleware(function (RequestInterface $request, DelegateInterface $next) {
    echo 'world';
});

$dispatcher = new Dispatcher([
    $middleware,
    $middleware2
]);

$response = $dispatcher->dispatch(new ServerRequest('GET', '/'));