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

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

d4h/finediff
============

PHP implementation of a Fine granularity Diff engine

1.0.4(8mo ago)151.5M↓35.6%8[3 issues](https://github.com/D4H/php-finediff/issues)[1 PRs](https://github.com/D4H/php-finediff/pulls)1MITPHPPHP ~8.1

Since Aug 5Pushed 8mo ago3 watchersCompare

[ Source](https://github.com/D4H/php-finediff)[ Packagist](https://packagist.org/packages/d4h/finediff)[ RSS](/packages/d4h-finediff/feed)WikiDiscussions 1.x Synced 2d ago

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

FineDiff
========

[](#finediff)

Originally written by Raymond Hill ()

[![Build Status](https://camo.githubusercontent.com/ae6999d8416b84d72712c3b64c323c719e83a5ad4adc6520ecb695c107a790c8/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6434682f7068702d66696e65646966662e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/d4h/php-finediff)[![Latest Stable Version](https://camo.githubusercontent.com/65b0301d91b5c717558720b842abc7eea5318432f1bc7a22c844280b3bd311bc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6434682f66696e65646966662e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/d4h/finediff)[![License](https://camo.githubusercontent.com/6ba0a49633cccdfc1af065f25178300dbc6c62bfea278d6f833933a9e8c0e880/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6434682f7068702d66696e65646966663f7374796c653d666c61742d737175617265)](#license)

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

[](#installation)

```
composer require d4h/finediff
```

Usage
-----

[](#usage)

### Render HTML

[](#render-html)

Render the difference between two strings as HTML:

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

This would then output:

```
string twone
```

You could change the granularity to `CogPowered\FineDiff\Granularity\Word`

```
$diff = new FineDiff\Diff(new FineDiff\Granularity\Word());
// Or via the setter method:
$diff->setGranularity(new FineDiff\Granularity\Word());
```

so the output is:

```
string onetwo
```

You do this by passing it into the Diff constructor:

### Grab opcode instructions

[](#grab-opcode-instructions)

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

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

This would then output:

```
c7d3i3:two
```

Render text using the opcodes:

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

Would output:

```
string two
```

Same with HTML:

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

Credits
-------

[](#credits)

Sponsored by [D4H](https://d4htechnologies.com/).

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance57

Moderate activity, may be stable

Popularity50

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~380 days

Recently: every ~475 days

Total

6

Last Release

256d ago

PHP version history (3 changes)1.0.0PHP &gt;=7.2.0

1.0.2PHP &gt;=7.4

1.0.3PHP ~8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1410358?v=4)[Hannes Van De Vreken](/maintainers/hannesvdvreken)[@hannesvdvreken](https://github.com/hannesvdvreken)

---

Top Contributors

[![hannesvdvreken](https://avatars.githubusercontent.com/u/1410358?v=4)](https://github.com/hannesvdvreken "hannesvdvreken (8 commits)")[![mrdan](https://avatars.githubusercontent.com/u/63897?v=4)](https://github.com/mrdan "mrdan (4 commits)")[![AndyGotfridt](https://avatars.githubusercontent.com/u/50306269?v=4)](https://github.com/AndyGotfridt "AndyGotfridt (2 commits)")[![boligolov](https://avatars.githubusercontent.com/u/1481397?v=4)](https://github.com/boligolov "boligolov (1 commits)")[![finagin](https://avatars.githubusercontent.com/u/11045296?v=4)](https://github.com/finagin "finagin (1 commits)")

---

Tags

diffstringtextfinediffopcode

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[lolli42/finediff

PHP implementation of a Fine granularity Diff engine

139.8M9](/packages/lolli42-finediff)[edgaras/strsim

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

2857.3k6](/packages/edgaras-strsim)

PHPackages © 2026

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