PHPackages                             icap/html-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. icap/html-diff

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

icap/html-diff
==============

A PHP5 library that diffs (compares) HTML files.

v1.1.0(10y ago)30117.7k↓11.8%4[2 issues](https://github.com/iCAPLyon1/HtmlDiff/issues)4PHPPHP &gt;=5.3.0

Since Oct 14Pushed 9y ago4 watchersCompare

[ Source](https://github.com/iCAPLyon1/HtmlDiff)[ Packagist](https://packagist.org/packages/icap/html-diff)[ RSS](/packages/icap-html-diff/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (5)Used By (4)

HtmlDiff
========

[](#htmldiff)

A PHP5 library that diffs (compares) HTML files.

This library is actually a transfer of the daisy-diff library for PHP, found [here](http://code.google.com/p/daisydiff/source/browse/trunk/daisydiff-php/) for gitgub, meeting the PSR-4 standards. The library was developped in 2008 and is used today by many wiki platforms (wikipedia, wikihub, gamepedia, etc). It is part of code of the MediaWiki package.

Setup
-----

[](#setup)

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

[](#requirements)

- PHP &gt;=5.3.0
- Pimple 1.0.\*
- Silex 1.0.\*

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

[](#installation)

The easiest way to install HtmlDiff is using [Composer](https://github.com/composer/composer)with the following requirement:

```
    {
        "require": {
        	...
            "icap/html-diff": ">=1.0.1"
        }
    }
```

Alternatively, you can [download the archive](https://github.com/iCAPLyon1/HtmlDiff/archive/master.zip)and add the src/ folder to PHP's include path:

```
    set_include_path('/path/to/src' . PATH_SEPARATOR . get_include_path());
```

Usage
-----

[](#usage)

To find and render the differences between two html blocks html you need include the *HtmlDiff* class

```
	use Icap\HtmlDiff\HtmlDiff;
```

and then initialize a new HtmlDiff class object with the following attributes:

- the old html text/block (String)
- the new html text/block (String)
- the option to enable or not formatting changes (Boolean) (set this to true if beside the adds and removes you also want to display the different style modifications of the nodes/elements)

Then call the outputDiff function of the class to retrieve the result with the compared version and the modifications.

```
	$htmlDiff = new HtmlDiff($oldText, $newText, true);
	$out = $htmlDiff->outputDiff();
	//Then
	$out->toString();//to get the compared version
	//And
	$out->getModifications();//to retrieve the number of differences/modifications between the two blocks.
```

The output is a [ChangeText](https://github.com/iCAPLyon1/HtmlDiff/blob/master/src/Icap/HtmlDiff/Html/ChangeText.php)

You can always refer to the demo/examples for further help. In the given examples we use two different styles to render the compared html result. Feel free to copy and use these styles in your application.

Modifications compared to the original library
----------------------------------------------

[](#modifications-compared-to-the-original-library)

- In the ChangeText object a new attribute was added (modifications) to count the differences found between the two texts. These differences are given in a form of an array ('added' =&gt; #, 'changed' =&gt; #, 'removed' =&gt; #)
- The details tooltip was removed
- All the MediaWiki general functions (which are defined [here](http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/GlobalFunctions.php?view=markup&pathrev=58267)) used by the HtmlDiff module, were replaced with some simple/dummy ones so as the module runs without them.
- In the converted html output all the 'added' and 'deleted' span tags were replaced by 'ins' and 'del' tags respectively for WAI compliance reasons.

Tests
-----

[](#tests)

Since the library is a tranfer of an already tested (hopefully) library, no tests were created or executed.

Known issues
------------

[](#known-issues)

There is a known issue with table comparison reported [here](http://code.google.com/p/daisydiff/issues/detail?id=8)Thow it is referring to the java version of the library, the same issue exists in the PHP version.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% 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 ~285 days

Total

4

Last Release

3743d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3414956?v=4)[eddymarques](/maintainers/eddymarques)[@eddymarques](https://github.com/eddymarques)

![](https://avatars.githubusercontent.com/u/2643253?v=4)[Vaince](/maintainers/Vaince)[@Vaince](https://github.com/Vaince)

![](https://avatars.githubusercontent.com/u/3414935?v=4)[Panos Tsavdaris](/maintainers/ptsavdar)[@ptsavdar](https://github.com/ptsavdar)

---

Top Contributors

[![ptsavdar](https://avatars.githubusercontent.com/u/3414935?v=4)](https://github.com/ptsavdar "ptsavdar (12 commits)")[![Christian-Krupa](https://avatars.githubusercontent.com/u/1899546?v=4)](https://github.com/Christian-Krupa "Christian-Krupa (1 commits)")[![dehenne](https://avatars.githubusercontent.com/u/751811?v=4)](https://github.com/dehenne "dehenne (1 commits)")

---

Tags

html diffdaisy diff

### Embed Badge

![Health badge](/badges/icap-html-diff/health.svg)

```
[![Health](https://phpackages.com/badges/icap-html-diff/health.svg)](https://phpackages.com/packages/icap-html-diff)
```

###  Alternatives

[randsonjs/inflect

A PHP class to handle words in Portuguese

1710.7k](/packages/randsonjs-inflect)

PHPackages © 2026

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