PHPackages                             fansipan/request-matcher - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. fansipan/request-matcher

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

fansipan/request-matcher
========================

PSR Request matcher

1.0.0(1y ago)01072MITPHPPHP ^7.2.5|^8.0

Since Nov 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/phanxipang/request-matcher)[ Packagist](https://packagist.org/packages/fansipan/request-matcher)[ Docs](https://github.com/phanxipang/request-matcher)[ RSS](/packages/fansipan-request-matcher/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (2)

Fansipan PSR-7 Request Matcher
==============================

[](#fansipan-psr-7-request-matcher)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4f5e8529e1358b35212856110e50879d9a66b68580586daf6b2c1dd4bceee18f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66616e736970616e2f726571756573742d6d6174636865722e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/fansipan/request-matcher)[![Github Actions](https://camo.githubusercontent.com/27e6d622950bac981a92a6f3240afb9b1f1fa35992a37e20d86f143f56ca41a6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7068616e786970616e672f726571756573742d6d6174636865722f74657374696e672e796d6c3f6272616e63683d6d61696e266c6162656c3d616374696f6e73266c6f676f3d676974687562267374796c653d666f722d7468652d6261646765)](https://github.com/phanxipang/request-matcher)[![Codecov](https://camo.githubusercontent.com/5fea3e56b2c5973a27b72cfdad04babec9ffc1e9196ebca7a5dc0b323ae20fad/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f7068616e786970616e672f726571756573742d6d6174636865723f6c6f676f3d636f6465636f76267374796c653d666f722d7468652d6261646765)](https://codecov.io/gh/phanxipang/request-matcher)[![Total Downloads](https://camo.githubusercontent.com/23367f2b3b9041ca85f908c4e2a3fa78a42e4f6e9c86f977509df320ad751bf1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66616e736970616e2f726571756573742d6d6174636865722e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/fansipan/request-matcher)[![Software License](https://camo.githubusercontent.com/9897f4467850972a38c7db9a4d38280b8fcdac0ada00e9c8c0a72ecfa8551653/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666f722d7468652d6261646765)](LICENSE.md)

PSR-7 request matcher equivalent of [Symfony's RequestMatcher](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/RequestMatcherInterface.php).

Installation
------------

[](#installation)

You may use Composer to install this package:

```
composer require fansipan/request-matcher
```

Usage
-----

[](#usage)

To create a matcher instance with your assertions, you can use the following example to match the request host:

```
use Fansipan\RequestMatcher\HostRequestMatcher;
use Psr\Http\Message\RequestInterface;

$matcher = new HostRequestMatcher('localhost');

// Matches http://localhost

/** @var RequestInterface $request */
$matcher->matches($request);
```

### Customer Request Matcher

[](#customer-request-matcher)

You can also create a matcher using a callback. For instance:

```
use Fansipan\RequestMatcher\CallbackRequestMatcher;
use Psr\Http\Message\RequestInterface;

$matcher = new CallbackRequestMatcher(static fn (RequestInterface $request) => $request->getUri()->getScheme() === 'https' && $request->getUri()->getHost() === 'my.app');
```

### Chain Request Matcher

[](#chain-request-matcher)

The example above can be grouped by using `ChainRequestMatcher`

```
use Fansipan\RequestMatcher\CallbackRequestMatcher;
use Fansipan\RequestMatcher\HostRequestMatcher;
use Fansipan\RequestMatcher\SchemeRequestMatcher;
use Psr\Http\Message\RequestInterface;

$matcher = new ChainRequestMatcher([
    new SchemeRequestMatcher('https'),
    new HostRequestMatcher('my.app'),
]);
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Lynh](https://github.com/jenky)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

554d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/783e915bb411d566e8f1035f197842db5e870a2a995b3943bcbe5db2f9abf09b?d=identicon)[Milano](/maintainers/Milano)

---

Top Contributors

[![jenky](https://avatars.githubusercontent.com/u/1808758?v=4)](https://github.com/jenky "jenky (8 commits)")

---

Tags

psrfansipanrequest-matcher

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fansipan-request-matcher/health.svg)

```
[![Health](https://phpackages.com/badges/fansipan-request-matcher/health.svg)](https://phpackages.com/packages/fansipan-request-matcher)
```

###  Alternatives

[psr/container

Common Container Interface (PHP FIG PSR-11)

10.0k1.0B3.7k](/packages/psr-container)[psr/clock

Common interface for reading the clock.

642332.9M343](/packages/psr-clock)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
