PHP code example of n1215 / http-request-matcher
1. Go to this page and download the library: Download n1215/http-request-matcher 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/ */
n1215 / http-request-matcher example snippets
// 1. implement RequestMatcherInterface or ServerRequestMatcherInterface. you can use RequestMatchResult concrete class.
class YourServerRequestMatcher implements ServerRequestMatcherInterface
{
public function match(ServerRequestInterface $request): RequestMatchResultInterface
{
// implement
}
}
// 2. use for PSR-7 Request
$matcher = new YourServerRequestMatcher();
/** @var \Psr\Http\Message\ServerRequestInterface $request */
$result = $matcher->match($request);
if ($result->isSuccess()) {
var_dump($result->getParams());
}