1. Go to this page and download the library: Download phoole/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/ */
phoole / middleware example snippets
use Phoole\Middleware\Queue;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\ServerRequest;
// create middleware queue with 404 response as default(last)
$mws = new Queue(new Response(404));
// add middlewares
$mws->add(
new LoggerMiddleware(),
new DispatcherMiddleware()
);
// process the request with middlewares
$response = $mws->handle(new ServerRequest('GET', 'http://bingo.com/get'));
// subqueue may need no default response if not the last in the main queue
$subQueue = (new Queue())->add(
new ResponseTimeMiddleware(),
new LoggingMiddleware()
);
// main middleware queue
$mws = (new Queue(new Response(404)))->add(
$subQueue,
new DispatcherMiddleware()
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.