PHPackages                             bariew/finediff - 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. bariew/finediff

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

bariew/finediff
===============

PHP implementation of a Fine granularity Diff engine

0.3.1(11y ago)19.5k↓50%MITPHPPHP &gt;=5.3.0

Since Mar 14Pushed 9y ago1 watchersCompare

[ Source](https://github.com/bariew/FineDiff)[ Packagist](https://packagist.org/packages/bariew/finediff)[ Docs](https://github.com/cogpowered/FineDiff)[ RSS](/packages/bariew-finediff/feed)WikiDiscussions master Synced 1mo ago

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

FineDiff
========

[](#finediff)

Originally written by Raymond Hill () FineDiff has been tweaked to bring it up to date with the modern world. That means documented, nicely formatted, tested code that can be easily extended.

[![Build Status](https://camo.githubusercontent.com/c8e78a0cc9fb8cb5b4bc6a4482c47726356412ad16cdca823bd842bd429d51d7/68747470733a2f2f7472617669732d63692e6f72672f6261726965772f46696e65446966662e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/bariew/FineDiff)

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

[](#installation)

**Composer**

The preferred way of using FineDiff is through [Composer](http://getcomposer.org).

Add the following to your composer.json file:

```
{
    "require": {
        "bariew/finediff": "0.3.*"
    }
}
```

Upgrading
---------

[](#upgrading)

**0.3.x** introduces a backwards incompatible version, so if you have stored opcodes do not upgrade!

`0.3.x` fixes a double encoding issue that generates a longer opcode than is needed.

Usage
-----

[](#usage)

**Render HTML**

Render as HTML the difference between two strings:

```
$diff = new bariew\FineDiff\Diff;
echo $diff->render('string one', 'string two');
```

This would then output:

```
string twone
```

You could change the granularity to `bariew\FineDiff\Granularity\Word` so the output is:

```
string onetwo
```

You do this by passing it into the Diff constructor:

```
$granularity = new bariew\FineDiff\Granularity\Word;
$diff        = new bariew\FineDiff\Diff($granularity);
```

**Grab opcode instructions**

Opcode instructions are what tell FineDiff how to change one string into another.

```
$diff = new bariew\FineDiff\Diff;
echo $diff->getOpcodes('string one', 'string two');
```

This would then output:

```
c7d3i3:two
```

Render text using the opcodes:

```
$render = new bariew\FineDiff\Render\Text;
echo $render->process('string one', 'c7d3i3:two');
```

Would output:

```
string two
```

Same with HTML:

```
$render = new bariew\FineDiff\Render\Html;
echo $render->process('string one', 'c7d3i3:two');
```

License
-------

[](#license)

Copyright (c) 2011 Raymond Hill () Copyright (c) 2013 Rob Crowe ()

Licensed under The MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Every ~143 days

Total

4

Last Release

4373d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8214f36975034f4134506744cd956e8415491006c1b3512af22bf75f91165f06?d=identicon)[bariew](/maintainers/bariew)

---

Top Contributors

[![bariew](https://avatars.githubusercontent.com/u/827508?v=4)](https://github.com/bariew "bariew (3 commits)")

---

Tags

diffstringtextfinediffopcode

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bariew-finediff/health.svg)

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

###  Alternatives

[lolli42/finediff

PHP implementation of a Fine granularity Diff engine

138.8M3](/packages/lolli42-finediff)[d4h/finediff

PHP implementation of a Fine granularity Diff engine

141.3M1](/packages/d4h-finediff)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[opis/string

Multibyte strings as objects

7120.9M7](/packages/opis-string)[localheinz/diff

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

4637.0M5](/packages/localheinz-diff)[phootwork/lang

Missing PHP language constructs

1224.8M8](/packages/phootwork-lang)

PHPackages © 2026

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