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

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

lolli42/finediff
================

PHP implementation of a Fine granularity Diff engine

1.1.2(6mo ago)138.8M—1.2%33MITPHPPHP &gt;=8.2CI passing

Since Mar 14Pushed 2mo ago2 watchersCompare

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

READMEChangelog (8)Dependencies (3)Versions (15)Used By (3)

[![Tests](https://github.com/lolli42/FineDiff/actions/workflows/tests.yml/badge.svg)](https://github.com/lolli42/FineDiff/actions/workflows/tests.yml)

FineDiff
========

[](#finediff)

FineDiff is a rather simple library to create HTML diff view of two strings:

```
echo (new Diff())->render('hello world', 'hello2 worlds');
```

```
hello2 worlds

```

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

[](#installation)

```
$ composer req lolli42/finediff

```

Tags
----

[](#tags)

- **1.1** Dropped PHP &lt;8.2
- **1.0** Dropped PHP &lt;7.2, has PHP &gt;=7.2 support, added multibyte support, forces strict types, E\_ALL error free
- **&lt;1.x** is identical to cogpowered/finediff from ()

Usage
-----

[](#usage)

Render the difference between two strings as HTML on a character basis:

```
echo (new Diff())->render('string one', 'string two');
```

```
string twone

```

Render the difference between two strings as HTML on a word basis:

```
echo (new Diff(new Word()))->render('string one', 'string two');
```

```
string onetwo

```

Special characters and entities are quoted by HTML renderer and multibyte strings are handled:

```
echo (new Diff())->render('foobaz', 'foobaz');
```

```
foo&lt;b&auml;rq&uuml;x&gt;baz

```

Algorithm
---------

[](#algorithm)

To create a diff-view between two string, an intermediate "Opcode" representation is created that specifies the differences form string one to string two. The renderer then takes this opcode and creates HTML from it. Note the opcode string is considered internal and may change in a backwards breaking way with younger library releases.

```
$diff = new Diff();
echo $diff->getOpcodes('hello world', 'hello2 worlds');
// c5i:2c6i:s
// Means: copy 5 chars "hello", then insert "2", then copy 6 chars " world", then insert "s"
echo $diff->process('hello wordl', 'c5i:2c6i:s');
// hello2 worlds
```

Running tests
-------------

[](#running-tests)

Full test run:

```
$ composer update
$ vendor/bin/phpunit

```

Restricting to single files:

```
$ composer update
$ vendor/bin/phpunit tests/DiffTest.php

```

Casual setup to run tests with xdebug (3.x) enabled, an IDE like phpstorm should then break point:

```
$ composer update
$ XDEBUG_MODE="debug,develop" XDEBUG_TRIGGER="foo" vendor/bin/phpunit

```

History
-------

[](#history)

- Originally written by Raymond Hill ()
- Tweaked to bring it up to date with the modern world. That means documented, nicely formatted, tested code that can be easily extended by Rob Crowe ()
- Added PHP 8 compatibility and multibyte string support by Christian Kuhn ()

License
-------

[](#license)

MIT License. See LICENSE file.

###  Health Score

63

—

FairBetter than 99% of packages

Maintenance77

Regular maintenance activity

Popularity53

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 96.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 ~384 days

Recently: every ~158 days

Total

13

Last Release

200d ago

Major Versions

0.3.1 → 1.0.02021-10-23

PHP version history (3 changes)0.0.1PHP &gt;=5.3.0

1.0.0PHP &gt;=7.2.0

1.1.0PHP &gt;=8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/88698?v=4)[TYPO3 GitHub Department](/maintainers/typo3)[@TYPO3](https://github.com/TYPO3)

![](https://www.gravatar.com/avatar/21bf0c815297c24ae76a3c08455b2b843f33010706043a3a99aaffe988968194?d=identicon)[lolli42](/maintainers/lolli42)

---

Top Contributors

[![lolli42](https://avatars.githubusercontent.com/u/2178068?v=4)](https://github.com/lolli42 "lolli42 (111 commits)")[![sbuerk](https://avatars.githubusercontent.com/u/1453466?v=4)](https://github.com/sbuerk "sbuerk (2 commits)")[![bariew](https://avatars.githubusercontent.com/u/827508?v=4)](https://github.com/bariew "bariew (1 commits)")[![mbrodala](https://avatars.githubusercontent.com/u/5037116?v=4)](https://github.com/mbrodala "mbrodala (1 commits)")

---

Tags

diffstringtextfinediffopcode

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[d4h/finediff

PHP implementation of a Fine granularity Diff engine

141.3M1](/packages/d4h-finediff)[opis/string

Multibyte strings as objects

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

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

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

Missing PHP language constructs

1224.8M8](/packages/phootwork-lang)[edgaras/strsim

Collection of string similarity and distance algorithms in PHP including Levenshtein, Damerau-Levenshtein, Jaro-Winkler, and more

2423.0k](/packages/edgaras-strsim)

PHPackages © 2026

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