PHP code example of kovagoz / http-middleware-closure-handler

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

    

kovagoz / http-middleware-closure-handler example snippets


$request = $serverRequestFactory
    ->createServerRequest('GET', '/')
    ->withAttribute('__handler', fn() => 'hello world!');

$middleware = new ClosureHandler($responseFactory, $streamFactory);

$response = $middleware->process($request, $nextHandler);

echo $response->getBody(); // Will print "hello world!"