PHPackages                             wikimedia/wikidiff2 - 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. wikimedia/wikidiff2

ActivePhp-ext[Utility &amp; Helpers](/categories/utility)

wikimedia/wikidiff2
===================

Wikidiff2 is a PHP extension which formats changes between two input texts, producing HTML or JSON.

1.14.2(1mo ago)8814GPL-2.0-or-laterPHPPHP &gt;=8.2

Since Jun 9Pushed 1mo ago4 watchersCompare

[ Source](https://github.com/wikimedia/mediawiki-php-wikidiff2)[ Packagist](https://packagist.org/packages/wikimedia/wikidiff2)[ RSS](/packages/wikimedia-wikidiff2/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (2)Used By (0)

wikidiff2
=========

[](#wikidiff2)

Wikidiff2 is a PHP extension which formats changes between two input texts, producing HTML or JSON.

It performs word-level diffs, including support for Thai word segmentation. It can detect moved and split lines.

Dependencies
------------

[](#dependencies)

- GCC 4.7+
- `libthai`, a Thai language support library . On Debian-based systems this also needs the `libthai0` and `libthai-dev` packages.

To build wikidiff2 as a PHP extension, you also need the `php-dev` and `pkg-config` packages.

Compilation and installation
----------------------------

[](#compilation-and-installation)

```
$ phpize
$ ./configure
$ make
$ sudo make install

```

License
-------

[](#license)

wikidiff2 is licensed under the GPL v2 or any later version.

Historically the PHP License was incompatible with the GPL, meaning that binaries were not redistributable. However that was resolved in 2026 with version 4 of the PHP License, which is merely the BSD-3-Clause license and explicitly GPL compatible.

See COPYING and  for more details.

Configuration
-------------

[](#configuration)

The following php.ini settings are supported:

### wikidiff2.moved\_line\_threshold

[](#wikidiff2moved_line_threshold)

Wikidiff2 estimates similarity of added and deleted lines based on changed character count. When the similarity of an added and deleted line is greater than this threshold, the lines are displayed as moved.

Range 0.0 .. 1.0. Default 0.4.

### wikidiff2.change\_threshold

[](#wikidiff2change_threshold)

Changed lines with a similarity value below this threshold will be split into a deleted line and added line. This helps matching up moved lines in some cases.

Range 0.0 .. 1.0. Default 0.2.

### wikidiff2.moved\_paragraph\_detection\_cutoff

[](#wikidiff2moved_paragraph_detection_cutoff)

When the number of added and deleted lines in a table diff is greater than this limit, no attempt to detect moved lines will be made.

Default 100.

### wikidiff2.max\_word\_level\_diff\_complexity

[](#wikidiff2max_word_level_diff_complexity)

When comparing two lines for changes within the line, a word-level diff will be done unless the product of the LHS word count and the RHS word count exceeds this limit.

Default 40000000.

Usage
-----

[](#usage)

The input is assumed to be UTF-8 encoded. Invalid UTF-8 may cause undesirable operation, such as truncation of the output, so the input should be validated by the application. The input text should have UNIX-style line endings.

### wikidiff2\_do\_diff

[](#wikidiff2_do_diff)

```
function wikidiff2_do_diff(string $text1, string $text2, int $numContextLines): string
```

Compare two strings `$text1` and `$text2`, and produce output formatted as a fragment of an HTML table, that is, a series of `` elements.

$numContextLines is the number of copied context lines shown before and after each change. Before each block of context lines and changes, a line number will appear as an HTML comment inside a tr/td, e.g.

```

```

This allows the application to localize line numbers.

### wikidiff2\_inline\_diff

[](#wikidiff2_inline_diff)

```
function wikidiff2_inline_diff(string $text1, string $text2, int $numContextLines): string
```

Compare two strings `$text1` and `$text2`, and produce output formatted as inline HTML.

### wikidiff2\_inline\_json\_diff

[](#wikidiff2_inline_json_diff)

```
function wikidiff2_inline_json_diff(string $text1, string $text2, int $numContextLines): string
```

Compare two strings `$text1` and `$text2` and produce output formatted as JSON. See the [JSON diff format documentation](https://www.mediawiki.org/wiki/Wikidiff2/JSON_diff_format).

### wikidiff2\_multi\_format\_diff

[](#wikidiff2_multi_format_diff)

```
function wikidiff2_multi_format_diff(string $text1, string $text2, array $options = []): array
```

Compare two strings `$text1` and `$text2` with an associative array of options:

- **numContextLines**: The number of context lines shown before and after each block
- **changeThreshold**: The minimum similarity a pair of lines must have to be detected as a change and shown as a word-level diff. If present, this overrides php.ini `wikidiff2.change_threshold`.
- **movedLineThreshold**: The minimum similarity a pair of lines must have to be detected as a moved line. If present, this overrides php.ini `wikidiff2.moved_line_threshold`.
- **maxMovedLines**: The maximum number of added or deleted lines, above which no move detection will be performed. If present, this overrides php.ini `moved_paragraph_detection_cutoff`.
- **maxWordLevelDiffComplexity**: The maximum complexity of a word-level diff. If the product of the word count in the LHS and RHS exceeds this value, a word-level diff will not be done. If present, this overrides php.ini `wikidiff2.max_word_level_diff_complexity`.
- **maxSplitSize**: The maximum number of lines in `$text2` which may be considered for a word-level diff against a single line of `$text1`. Default: 1.
- **initialSplitThreshold**: The minimum similarity which must be maintained during a split detection search. The search terminates when the similarity falls below this level. Default: 0.1.
- **finalSplitThreshold**: The minimum similarity which must be achieved in order to display the comparison between one line and several lines as a split. Default 0.6.
- **formats**: An array of desired formats. Each format is one of the following strings: `table`, `inline` or `inlineJSON`. The default is `['table']`.

The return value is an associative array of formatted outputs. The key of each element is the format name `table`, `inline` or `inlineJSON`, and the value is a string.

### wikidiff2\_version

[](#wikidiff2_version)

```
function wikidiff2_version(): string {}
```

Produces the same thing as `phpversion('wikidiff2')`. Probably should be deprecated.

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance91

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor4

4 contributors hold 50%+ of commits

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

Unknown

Total

1

Last Release

48d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/716c86d71cbf921e7912a505f89d799de398fc0a3af0bd4c8862834b2d642bd7?d=identicon)[wikimedia](/maintainers/wikimedia)

---

Top Contributors

[![tstarling](https://avatars.githubusercontent.com/u/389141?v=4)](https://github.com/tstarling "tstarling (31 commits)")[![MaxSem](https://avatars.githubusercontent.com/u/1260606?v=4)](https://github.com/MaxSem "MaxSem (14 commits)")[![lavagetto](https://avatars.githubusercontent.com/u/1475424?v=4)](https://github.com/lavagetto "lavagetto (8 commits)")[![WMDE-Fisch](https://avatars.githubusercontent.com/u/8479008?v=4)](https://github.com/WMDE-Fisch "WMDE-Fisch (7 commits)")[![legoktm](https://avatars.githubusercontent.com/u/81392?v=4)](https://github.com/legoktm "legoktm (7 commits)")[![Ladsgroup](https://avatars.githubusercontent.com/u/5351225?v=4)](https://github.com/Ladsgroup "Ladsgroup (5 commits)")[![Daimona](https://avatars.githubusercontent.com/u/38216014?v=4)](https://github.com/Daimona "Daimona (5 commits)")[![thiemowmde](https://avatars.githubusercontent.com/u/6576639?v=4)](https://github.com/thiemowmde "thiemowmde (4 commits)")[![adamwight](https://avatars.githubusercontent.com/u/819437?v=4)](https://github.com/adamwight "adamwight (4 commits)")[![paravoid](https://avatars.githubusercontent.com/u/1330796?v=4)](https://github.com/paravoid "paravoid (3 commits)")[![atdt](https://avatars.githubusercontent.com/u/376462?v=4)](https://github.com/atdt "atdt (3 commits)")[![reedy](https://avatars.githubusercontent.com/u/67615?v=4)](https://github.com/reedy "reedy (3 commits)")[![tonisevener](https://avatars.githubusercontent.com/u/3620196?v=4)](https://github.com/tonisevener "tonisevener (3 commits)")[![remicollet](https://avatars.githubusercontent.com/u/270445?v=4)](https://github.com/remicollet "remicollet (2 commits)")[![dayllanmaza](https://avatars.githubusercontent.com/u/680583?v=4)](https://github.com/dayllanmaza "dayllanmaza (2 commits)")[![Rillke](https://avatars.githubusercontent.com/u/2311611?v=4)](https://github.com/Rillke "Rillke (1 commits)")[![samwilson](https://avatars.githubusercontent.com/u/213655?v=4)](https://github.com/samwilson "samwilson (1 commits)")[![skizzerz](https://avatars.githubusercontent.com/u/72652?v=4)](https://github.com/skizzerz "skizzerz (1 commits)")[![jdforrester](https://avatars.githubusercontent.com/u/881572?v=4)](https://github.com/jdforrester "jdforrester (1 commits)")[![bd808](https://avatars.githubusercontent.com/u/6469?v=4)](https://github.com/bd808 "bd808 (1 commits)")

### Embed Badge

![Health badge](/badges/wikimedia-wikidiff2/health.svg)

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

###  Alternatives

[robicch/jquery-gantt

Twproject Gantt editor is a free online tool for creating and sharing Gantts

2.2k169.0k](/packages/robicch-jquery-gantt)[spatie/lighthouse-php

Run Google Lighthouse using PHP

26861.5k2](/packages/spatie-lighthouse-php)

PHPackages © 2026

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