PHP code example of apitte / middlewares
1. Go to this page and download the library: Download apitte/middlewares 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/ */
apitte / middlewares example snippets
namespace App\Api\Middleware;
use Contributte\Middlewares\IMiddleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class ExampleMiddleware implements IMiddleware
{
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface
{
// Call next middleware in a row
$response = $next($request, $response);
// Return response
return $response;
}
}