PHPackages                             coduo/php-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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. coduo/php-matcher

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

coduo/php-matcher
=================

PHP Matcher enables you to match values with patterns

6.0.18(6mo ago)84313.0M↓40%85[4 issues](https://github.com/coduo/php-matcher/issues)[2 PRs](https://github.com/coduo/php-matcher/pulls)20MITPHPPHP ~8.3 || ~8.4 || ~8.5CI passing

Since May 8Pushed 1w ago17 watchersCompare

[ Source](https://github.com/coduo/php-matcher)[ Packagist](https://packagist.org/packages/coduo/php-matcher)[ Fund](https://flow-php.com/sponsor)[ GitHub Sponsors](https://github.com/norberttech)[ RSS](/packages/coduo-php-matcher/feed)WikiDiscussions 6.x Synced 1w ago

READMEChangelog (10)Dependencies (6)Versions (91)Used By (20)

PHP Matcher
===========

[](#php-matcher)

[![Type Coverage](https://camo.githubusercontent.com/0da974ed03a339fa649dde3487f9f913800a7fc3dc8cd16374064aafb4873333/68747470733a2f2f73686570686572642e6465762f6769746875622f636f64756f2f7068702d6d6174636865722f636f7665726167652e737667)](https://shepherd.dev/coduo/php-matcher)

Library created for testing all kinds of JSON/XML/TXT/Scalar values against patterns.

API:

```
PHPMatcher::match($value = '{"foo": "bar"}', $pattern = '{"foo": "@string@"}') : bool;
PHPMatcher::backtrace() : Backtrace;
PHPMatcher::error() : ?string;
```

It was built to simplify API's functional testing.

- [![Test Suite](https://github.com/coduo/php-matcher/actions/workflows/test-suite.yml/badge.svg?branch=6.x)](https://github.com/coduo/php-matcher/actions/workflows/test-suite.yml) - [6.x README](https://github.com/coduo/php-matcher/tree/6.x/README.md) PHP &gt;= 8.3 &lt;= 8.5
- [5.x README](https://github.com/coduo/php-matcher/tree/5.x/README.md) PHP &gt;= 7.2 &lt; 8.0
- [5.0 README](https://github.com/coduo/php-matcher/tree/5.0/README.md) PHP &gt;= 7.2 &lt; 8.0
- [4.0.\* README](https://github.com/coduo/php-matcher/tree/4.0/README.md) PHP &gt;= 7.2 &lt; 8.0
- [3.2.\* README](https://github.com/coduo/php-matcher/tree/3.2/README.md) PHP &gt;= 7.0 &lt; 8.0
- [3.1.\* README](https://github.com/coduo/php-matcher/tree/3.1/README.md) PHP &gt;= 7.0 &lt; 8.0

[![Latest Stable Version](https://camo.githubusercontent.com/41f8643ffa4b74d5bb783d646644a0a457f3065b55a901ff529c40af0eeef0bf/68747470733a2f2f706f7365722e707567782e6f72672f636f64756f2f7068702d6d6174636865722f762f737461626c65)](https://packagist.org/packages/coduo/php-matcher)[![Total Downloads](https://camo.githubusercontent.com/673a6b7bf358593e548880d6464dcab757c517490f0a832a6d1f20b99800122a/68747470733a2f2f706f7365722e707567782e6f72672f636f64756f2f7068702d6d6174636865722f646f776e6c6f616473)](https://packagist.org/packages/coduo/php-matcher)[![Latest Unstable Version](https://camo.githubusercontent.com/931c22040f5856c98995639aadb0c796da9a1759de383da0011e5a57960a71fd/68747470733a2f2f706f7365722e707567782e6f72672f636f64756f2f7068702d6d6174636865722f762f756e737461626c65)](https://packagist.org/packages/coduo/php-matcher)[![License](https://camo.githubusercontent.com/fcb2ab57d83c5472718cbceb52f2f85ca806e2772843ae518024af308c8f4a6c/68747470733a2f2f706f7365722e707567782e6f72672f636f64756f2f7068702d6d6174636865722f6c6963656e7365)](https://packagist.org/packages/coduo/php-matcher)

Sandbox
-------

[](#sandbox)

Feel free to play first with [Sandbox](https://php-matcher.norbert.tech/)

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

[](#installation)

Require new dev dependency using composer:

```
composer require --dev "coduo/php-matcher"

```

Basic usage
-----------

[](#basic-usage)

### Direct PHPMatcher usage

[](#direct-phpmatcher-usage)

```
