PHPackages                             123dok/php-diff - 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. 123dok/php-diff

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

123dok/php-diff
===============

A comprehensive library for generating differences between two hashable objects (strings or arrays).

v1.2.1(8y ago)0630BSD-3-ClausePHPPHP &gt;= 5.4

Since May 5Pushed 8y ago1 watchersCompare

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

READMEChangelog (1)DependenciesVersions (4)Used By (0)

PHP Diff Class
--------------

[](#php-diff-class)

[![SensioLabsInsight](https://camo.githubusercontent.com/01caa7fba335b8a55c4db921f5c60395c05050e695806dfe38487f2eb84ba389/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f61613630396564622d636462312d343563662d616435312d6166626461623438663661312f6d696e692e706e67)](https://insight.sensiolabs.com/projects/aa609edb-cdb1-45cf-ad51-afbdab48f6a1)

[![Latest Version](https://camo.githubusercontent.com/f8d4a5010f01d2c46a52871cfe7fa9b25c150f9a4e85d81401d89d7bc015f7db/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f4a426c6f6e642f7068702d646966662e7376673f7374796c653d666c61742d737175617265266c6162656c3d52656c65617365)](https://github.com/JBlond/php-diff/releases)

Introduction
------------

[](#introduction)

A comprehensive library for generating differences between two hashable objects (strings or arrays). Generated differences can be rendered in all of the standard formats including:

- Unified
- Context
- Inline HTML
- Side by Side HTML

The logic behind the core of the diff engine (ie, the sequence matcher) is primarily based on the Python difflib package. The reason for doing so is primarily because of its high degree of accuracy.

Example Use
-----------

[](#example-use)

A quick usage example can be found in the example/ directory and under example.php.

[![Example Image](https://github.com/jblond/php-diff/raw/master/readme.png "Example")](https://github.com/jblond/php-diff/raw/master/readme.png)

Requirements
------------

[](#requirements)

PHP Multibyte String

Merge files using jQuery
------------------------

[](#merge-files-using-jquery)

Xiphe has build a jQuery plugin with that you can merge the compared files. Have a look at [jQuery-Merge-for-php-diff](https://github.com/Xiphe/jQuery-Merge-for-php-diff).

Todo
----

[](#todo)

- Ability to ignore blank line changes
- 3 way diff support
- Performance optimizations

License (BSD License)
---------------------

[](#license-bsd-license)

Copyright (c) 2009 Chris Boulton Copyright (c) 2015 Mario Brandt

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the Chris Boulton nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

```
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 77.5% 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 ~169 days

Total

3

Last Release

2962d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2509658?v=4)[Stupid Dev](/maintainers/vuthaihoc)[@vuthaihoc](https://github.com/vuthaihoc)

---

Top Contributors

[![JBlond](https://avatars.githubusercontent.com/u/2391810?v=4)](https://github.com/JBlond "JBlond (55 commits)")[![chrisboulton](https://avatars.githubusercontent.com/u/98472?v=4)](https://github.com/chrisboulton "chrisboulton (6 commits)")[![kelunik](https://avatars.githubusercontent.com/u/2743004?v=4)](https://github.com/kelunik "kelunik (2 commits)")[![vuthaihoc](https://avatars.githubusercontent.com/u/2509658?v=4)](https://github.com/vuthaihoc "vuthaihoc (2 commits)")[![joshfraser](https://avatars.githubusercontent.com/u/982234?v=4)](https://github.com/joshfraser "joshfraser (1 commits)")[![dgarrett](https://avatars.githubusercontent.com/u/1408738?v=4)](https://github.com/dgarrett "dgarrett (1 commits)")[![kriss0r](https://avatars.githubusercontent.com/u/476914?v=4)](https://github.com/kriss0r "kriss0r (1 commits)")[![maxxer](https://avatars.githubusercontent.com/u/240201?v=4)](https://github.com/maxxer "maxxer (1 commits)")[![Xiphe](https://avatars.githubusercontent.com/u/911218?v=4)](https://github.com/Xiphe "Xiphe (1 commits)")[![jensklose](https://avatars.githubusercontent.com/u/1216675?v=4)](https://github.com/jensklose "jensklose (1 commits)")

### Embed Badge

![Health badge](/badges/123dok-php-diff/health.svg)

```
[![Health](https://phpackages.com/badges/123dok-php-diff/health.svg)](https://phpackages.com/packages/123dok-php-diff)
```

###  Alternatives

[nikolaposa/version

Value Object that represents a SemVer-compliant version number.

1406.4M16](/packages/nikolaposa-version)[whatthejeff/nyancat-scoreboard

Nyan Cat Scoreboard

19985.0k4](/packages/whatthejeff-nyancat-scoreboard)[symfony/ux-swup

Swup integration for Symfony

33147.8k1](/packages/symfony-ux-swup)

PHPackages © 2026

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