PHPackages                             vielhuber/comparehelper - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. vielhuber/comparehelper

ActiveLibrary[Testing &amp; Quality](/categories/testing)

vielhuber/comparehelper
=======================

small php helper for comparing api responses in your tests.

1.1.4(2mo ago)1532↓25%1MITPHPPHP &gt;=7.4

Since Jul 25Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/vielhuber/comparehelper)[ Packagist](https://packagist.org/packages/vielhuber/comparehelper)[ RSS](/packages/vielhuber-comparehelper/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (16)Used By (1)

[![build status](https://github.com/vielhuber/comparehelper/actions/workflows/ci.yml/badge.svg)](https://github.com/vielhuber/comparehelper/actions)

📑 comparehelper 📑
=================

[](#-comparehelper-)

comparehelper is a small php helper for comparing api responses in your tests.

installation
------------

[](#installation)

install once with composer:

```
composer require vielhuber/comparehelper

```

then add this to your files:

```
require __DIR__ . '/vendor/autoload.php';
use vielhuber\comparehelper\comparehelper;
```

usage
-----

[](#usage)

```
comparehelper::compare($var1, $var2); // true|false
```

you can use the following placeholders:

- `*`: any datatype
- `#STR#`: any string
- `#INT#`: any numeric value

examples
--------

[](#examples)

```
comparehelper::compare('foo', 'foo'); // true

comparehelper::compare(42, 42); // true

comparehelper::compare(
    [
        'foo' => 'bar'
    ],
    [
        'foo' => 'bar',
        'foo2' => 'bar'
    ]
); // false

comparehelper::compare(
    [
        'foo' => 'bar',
        'bar' => ['baz', 42]
    ],
    [
        '#STR' => '*',
        'bar' => ['#STR#', '#INT#']
    ]
); // true

// ordering is lazy
comparehelper::compare(['foo', 'bar'], ['bar', 'foo']); // true
comparehelper::compare(['#INT#', '#STR#'], [42, 'foo']); // true
comparehelper::compare(['#INT#', '#STR#'], ['foo', 42]); // false
comparehelper::compare(['foo' => 7, 'bar' => 42], ['bar' => 42, 'foo' => 7]); // true
comparehelper::compare(['#INT#' => 7, '#STR#' => 42], [7 => 7, 'foo' => 42]); // true
comparehelper::compare(['#INT#' => 7, '#STR#' => 42], ['foo' => 42, 7 => 7]); // false

// datatypes are strict
comparehelper::compare(42, '42'); // false
```

phpunit integration
-------------------

[](#phpunit-integration)

for better diff output in tests, use `assertEquals()` instead of `compare()`:

```
// instead of:
$this->assertTrue(comparehelper::compare($expected, $actual));

// use this for better diffs:
comparehelper::assertEquals($expected, $actual);

// example:
comparehelper::assertEquals(['id' => '#INT#', 'name' => '#STR#', 'status' => 'active'], $apiResponse);
```

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance83

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity70

Established project with proven stability

 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

Every ~197 days

Recently: every ~18 days

Total

15

Last Release

88d ago

PHP version history (3 changes)1.0.0PHP &gt;=5.6

1.0.8PHP &gt;=8.1

1.1.1PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/d959b840f9893a14dfc78f65588f427d5bf606b885616e95dbe5a11199a8fc21?d=identicon)[vielhuber](/maintainers/vielhuber)

---

Top Contributors

[![vielhuber](https://avatars.githubusercontent.com/u/3183737?v=4)](https://github.com/vielhuber "vielhuber (18 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vielhuber-comparehelper/health.svg)

```
[![Health](https://phpackages.com/badges/vielhuber-comparehelper/health.svg)](https://phpackages.com/packages/vielhuber-comparehelper)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[phpspec/phpspec

Specification-oriented BDD framework for PHP 7.1+

1.9k36.7M3.1k](/packages/phpspec-phpspec)

PHPackages © 2026

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