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(1mo ago)28291MITPHPPHP ^8.2CI passing

Since Aug 30Pushed 1mo 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 1mo ago

READMEChangelogDependencies (20)Versions (8)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

45

—

FairBetter than 92% of packages

Maintenance89

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.1% 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

56d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/79712a8d56f2fa15f6c02e017a1fa6aebadf833d03a25ee86c34413375e5f621?d=identicon)[michiruf](/maintainers/michiruf)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (4 commits)")[![michiruf](https://avatars.githubusercontent.com/u/8984363?v=4)](https://github.com/michiruf "michiruf (2 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-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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