PHPackages                             ofmadsen/php-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. ofmadsen/php-differ

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

ofmadsen/php-differ
===================

Creates diff between two strings, lines or words

0.1.0(7y ago)0311MITPHPPHP ^7.1

Since Nov 4Pushed 7y ago1 watchersCompare

[ Source](https://github.com/ofmadsen/php-differ)[ Packagist](https://packagist.org/packages/ofmadsen/php-differ)[ RSS](/packages/ofmadsen-php-differ/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

PHP Differ
==========

[](#php-differ)

Library for creating diff between two strings, lines or words. It was created as a learning experience for myself, and published as it may be usable for others.

[![Build Status](https://camo.githubusercontent.com/40a6ec3b39b0f47c27b89a100bb531bb39da05166d5b4dd59b62c3e1be581a99/68747470733a2f2f7472617669732d63692e6f72672f6f666d616473656e2f7068702d6469666665722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ofmadsen/php-differ)

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

[](#installation)

Install the latest version with:

```
$ composer require ofmadsen/php-differ
```

Algorithms
----------

[](#algorithms)

- `Madsen\Diff\Algorithm\Myers`, described in Eugene W. Myers' 1986 [paper](http://www.xmailserver.org/diff2.pdf).

Usage
-----

[](#usage)

```
$algorithm = new Madsen\Diff\Algorithm\Myers();
$differ = new Madsen\Diff\Differ($algorithm);

// $a and $b are strings
$diff = $differ->diffLines($a, $b); // Also support ::diffWords()

// $diff is Madsen\Diff\Diff that can be iterated:
foreach ($diff as $chunk) {
    // $chunk is an Madsen\Diff\Chunk\AbstractChunk object; AddedChunk, RemovedChunk or UnchangedChunk
    $content = $chunk->getContent();
}

$added = $diff->countAdded(); // Get the number of added chunks
$removed = $diff->countRemoved(); // Get the number of removed chunks
$unchanged = $diff->countUnchanged(); // Get the number of unchanged chunks
```

Contribution
------------

[](#contribution)

All are welcome to contribute to PHP Differ. Please get in touch before making large features and/or major refactoring. Needlessly to say the coding style must be followed and full test coverage is required.

License
-------

[](#license)

PHP Differ is available under the MIT License - see the [`LICENSE`](LICENSE) file for details.

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

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

2797d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2144803?v=4)[Oliver Finn Madsen](/maintainers/ofmadsen)[@ofmadsen](https://github.com/ofmadsen)

---

Top Contributors

[![ofmadsen](https://avatars.githubusercontent.com/u/2144803?v=4)](https://github.com/ofmadsen "ofmadsen (2 commits)")

---

Tags

diff

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ofmadsen-php-differ/health.svg)

```
[![Health](https://phpackages.com/badges/ofmadsen-php-differ/health.svg)](https://phpackages.com/packages/ofmadsen-php-differ)
```

###  Alternatives

[jfcherng/php-diff

A comprehensive library for generating differences between two strings in multiple formats (unified, side by side HTML etc).

4785.8M71](/packages/jfcherng-php-diff)[caxy/php-htmldiff

A library for comparing two HTML files/snippets and highlighting the differences using simple HTML.

21522.3M22](/packages/caxy-php-htmldiff)[localheinz/diff

Fork of sebastian/diff for use with ergebnis/composer-normalize

4741.1M9](/packages/localheinz-diff)[diff/diff

Small standalone library for representing differences between data structures, computing such differences, and applying them as patches

2031.7M14](/packages/diff-diff)[mkalkbrenner/php-htmldiff-advanced

An add-on for the php-htmldiff library for comparing two HTML files/snippets and highlighting the differences using simple HTML.

3618.9M1](/packages/mkalkbrenner-php-htmldiff-advanced)[yetanotherape/diff-match-patch

Port of the google-diff-match-patch (https://github.com/google/diff-match-patch) lib to PHP

159964.9k15](/packages/yetanotherape-diff-match-patch)

PHPackages © 2026

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