PHPackages                             michiruf/laravel-collection-differ - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. michiruf/laravel-collection-differ

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

michiruf/laravel-collection-differ
==================================

Tiny helper to diff collections

0.4(3mo ago)21.2k[1 PRs](https://github.com/michiruf/laravel-collection-differ/pulls)1MITPHPPHP ^8.2CI passing

Since Aug 30Pushed 1w ago1 watchersCompare

[ Source](https://github.com/michiruf/laravel-collection-differ)[ Packagist](https://packagist.org/packages/michiruf/laravel-collection-differ)[ Docs](https://github.com/michiruf/laravel-collection-differ)[ GitHub Sponsors](https://github.com/michiruf)[ RSS](/packages/michiruf-laravel-collection-differ/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (20)Versions (9)Used By (1)

Laravel Collection Differ
=========================

[](#laravel-collection-differ)

[![Run Tests](https://github.com/michiruf/laravel-collection-differ/actions/workflows/run-tests.yml/badge.svg)](https://github.com/michiruf/laravel-collection-differ/actions/workflows/run-tests.yml)

Tiny helper to diff collections.

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

[](#installation)

```
composer require michiruf/laravel-collection-differ
```

Usage
-----

[](#usage)

Result usage example:

```
$result = collect([1, 2, 3])->differ([2, 4])->diff();

dump($result->unmatchedSource); // [1, 3]
dump($result->unmatchedDestination); // [4]
dump($result->matched); // [[2, 2]]
```

Callbacks usage example:

```
ProductModel::all()
    ->differ(ProductApi::getAll())
    ->handleUnmatchedSourceUsing(fn (ProductModel $model) => $model->delete())
    ->handleUnmatchedDestinationUsing(fn (ProductDto) $dto => ProductModel::createFromDto($dto))
    ->handleMatchedUsing(fn (ProductModel $model, ProductDto $dto) => $model->updateWithDto($dto))
    ->validateUniqueness() // throw if identifiers are not unique
    ->diff();
```

Identifier usage example:

```
ProductModel::all()
    ->differ(ProductApi::getAll())
    ->identifySourceUsing(fn (ProductModel $model) => $model->id)
    ->identifyDestinationUsing('meta.id') // or: fn (ProductDto $dto) => $dto->meta->id
    ->validateUniqueness() // throw if identifiers are not unique
    ->diff();
```

For additional examples, have at look at the [tests](tests/Unit/Support/CollectionDifferTest.php).

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance90

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.6% 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 ~187 days

Total

4

Last Release

109d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8984363?v=4)[Michael Ruf](/maintainers/michiruf)[@michiruf](https://github.com/michiruf)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")[![michiruf](https://avatars.githubusercontent.com/u/8984363?v=4)](https://github.com/michiruf "michiruf (3 commits)")

---

Tags

laravelmichiruflaravel-collection-differ

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/michiruf-laravel-collection-differ/health.svg)

```
[![Health](https://phpackages.com/badges/michiruf-laravel-collection-differ/health.svg)](https://phpackages.com/packages/michiruf-laravel-collection-differ)
```

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124603.0k](/packages/worksome-exchange)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

199.4k](/packages/tarfin-labs-event-machine)

PHPackages © 2026

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