n1215 / http-request-matcher
Matcher interface for PSR-7 HTTP request, like preg_match() for string.
v1.0.0
2017-12-08 10:00 UTC
Requires
- php: >=7.1.0
- psr/http-message: ^1.0
Requires (Dev)
- phpunit/phpunit: ^6.5
- zendframework/zend-diactoros: ^1.4
This package is auto-updated.
Last update: 2024-11-11 21:50:03 UTC
README
Matcher interface for PSR-7 HTTP request, like preg_match() for string.
Usage
// 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()); }