PHP code example of webimpress / http-middleware-compatibility
1. Go to this page and download the library: Download webimpress/http-middleware-compatibility 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/ */
webimpress / http-middleware-compatibility example snippets
namespace MyNamespace;
use Psr\Http\Message\ServerRequestInterface;
use Webimpress\HttpMiddlewareCompatibility\HandlerInterface;
use Webimpress\HttpMiddlewareCompatibility\MiddlewareInterface;
class MyMiddleware implements MiddlewareInterface
{
public function process(ServerRequestInterface $request, HandlerInterface $handler)
{
// ...
}
}
namespace MyNamespace;
use Psr\Http\Message\ServerRequestInterface;
use Webimpress\HttpMiddlewareCompatibility\HandlerInterface;
use Webimpress\HttpMiddlewareCompatibility\MiddlewareInterface;
use const Webimpress\HttpMiddlewareCompatibility\HANDLER_METHOD;
class MyMiddleware implements MiddlewareInterface
{
public function process(ServerRequestInterface $request, HandlerInterface $handler)
{
return $handler->{HANDLER_METHOD}($request);
}
}