NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist, #1284 most downloaded on Packagist
A comprehensive library for generating differences between two strings in multiple formats (unified, side by side HTML etc).
Latest stable
7.0.1
Last release 5 months ago
22 Jun 2026
Ships unpredictably
gaps range from 1 weeks to 2.1 years
Most releases are documented
notes for 53 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
8 years old
151 releases · first in 2018
Drag across the ruler to compare, or tap a release to open it.
Add Combined renderer option: mergeThreshold.
Combined renderer option: mergeThreshold.Combined: do not merge blocks which change too much.
Combined: do not merge blocks which change too much. (https://github.com/jfcherng/php-diff/issues/20#issuecomment-596088928)This release brings various fixes for Context and Unified mostly.
This release brings various fixes for Context and Unified mostly.
DiffHelper::calculateFiles() for empty files.context is set to 0.Unified line numbers when context is 0.Context output.Context/Unified output for EOL at EOF. (https://github.com/jfcherng/php-diff/issues/23)Your coding agent can read these notes before it upgrades. Set up the MCP server →
Improve Combined renderer output for newlines.
Combined renderer output for newlines. (https://github.com/jfcherng/php-diff/commit/41c6d0b5ef06d0b0b3ea002aa45f1bebbd2914a0#commitcomment-37651644)Fix there should not be \n in the Combined renderer output.
\n in the Combined renderer output.demo.php for textual renderer outputs.Allow overriding SCSS variables.
new if we can only show either the old or the new.Add new HTML renderer: Combined
Add new HTML renderer: Combined (https://github.com/jfcherng/php-diff/pull/22)
This renderer is suitable for articles and always has no line number.
CSS: SideBySide stripe background uses background-attachement: fixed;. (So I give up, non-fixed stripes always may be misaligned.)
CSS: SideBySide stripe background uses background-attachement: fixed;.
(So I give up, non-fixed stripes always may be misaligned.)
<details>
previous:
current:
</details>
CSS: Make SideBySide stripe background better aligned across line.
CSS: Make SideBySide stripe background better aligned across line.
background-attachment: fixed; should fix this perfectly but it will make you feel stripes are scrolling when you scroll.
CSS: Make empty table cells have normal height.
CSS: Make empty table cells have normal height.
CSS: Nonexistenet lines in SideBySide are shown as stripes.
This change also reverts "Merge SideBySide insert/delete/equal columns when lineNumbers is false." since stripes are quite distinguishable. And it's more consistent to most diff softwares.
Add a new constant: Differ::CONTEXT_ALL, which can be used for the context differ option
to show the whole source text in the output diff. (https://github.com/jfcherng/php-diff/issues/8)
It's just a large integer without possible overflow during calculation.
Fix SideBySide renderer wrong new line numbers.
SideBySide renderer wrong new line numbers.Merge SideBySide insert/delete/equal columns when lineNumbers is false.
SideBySide insert/delete/equal columns when lineNumbers is false.Fix SideBySide renderer fatal error.
SideBySide renderer fatal error.- Fix typo: Woker -> Worker.
Woker -> Worker.Add renderer option: lineNumbers.
lineNumbers. (#19)- Add French (fra) translation.
French (fra) translation.Remove dep: nicmart/string-template. (I should introduce this only if we really need to use it.)
nicmart/string-template. (I should introduce this only if we really need to use it.)Allow rendering HTML result with the JSON result.
// use the JSON result to render in HTML
$jsonResult = DiffHelper::calculate($old, $new, 'Json'); // may store the JSON result in your Database
$htmlRenderer = RendererFactory::make('Inline');
$result = $htmlRenderer->renderArray(json_decode($jsonResult, true));
- Add Turkish (tur) translation.
Turkish (tur) translation.Add renderer option: resultForIdenticals. This is used to customize the returned diff when the new and the old are identical.
resultForIdenticals. This is used to customize the returned diff when the new and the old are identical. (#12)Add Portuguese (por) translation.
Portuguese (por) translation.PSR-12.Fix renderer option language cannot be an array.
language cannot be an array. (#11)Add renderer option: wrapperClasses.
wrapperClasses.Sass: replace compass/css3 functions with dart-sass built-in.
compass/css3 functions with dart-sass built-in.There is no new feature or fix. 6.0.0 is just a massive clean up / API renaming release.
There is no new feature or fix. 6.0.0 is just a massive clean up / API renaming release.
See https://github.com/jfcherng/php-diff/blob/v6/UPGRADING/UPGRADING_v6.md for upgrading.
This release is functionally identical to 5.2.1. Just to tag that 5.2.2 is the final v5 release.
This release is functionally identical to 5.2.1. Just to tag that 5.2.2 is the final v5 release.
You may consider upgrading to v6.
Fix Diff::getOldNewComparison() should use finalize().
Diff::getOldNewComparison() should use finalize().Deprecate the static AbstractRenderer::getIdenticalResult(). Use the non-static AbstractRenderer::getResultForIdenticals() instead.
AbstractRenderer::getIdenticalResult(). Use the non-static AbstractRenderer::getResultForIdenticals() instead.Fix DiffHelp::getTemplatesInfo() typos.
DiffHelp::getTemplatesInfo() typos.Add DiffHelper::calculateFiles()
DiffHelper::calculateFiles()DiffHelper::getProjectDirectory()DiffHelper::getStyleSheet()INFO['type'] for renderersphpunit/phpunit 7.5DiffHelper::getTemplatesInfo() and DiffHelper::getStyleSheet()Fix Json renderer with empty changes.
Json renderer with empty changes.Fix squizlabs/php_codesniffer should be in require-dev.
squizlabs/php_codesniffer should be in require-dev.Add renderer option: outputTagAsString.
outputTagAsString.jfcherng/php-sequence-matcher ^3.0Diff::setAB()Diff::setA()Diff::setB()Diff::getA()Diff::getB()See https://github.com/jfcherng/php-diff/blob/v5/UPGRADING/UPGRADING_v5.md for upgrading.
You may consider upgrading to v5.
You may consider upgrading to v5.
Adapt some non-breaking changes from the master branch.
You may consider upgrading to v5.
Fix DiffHelp::getTemplatesInfo() typos.
DiffHelp::getTemplatesInfo() typos.Add DiffHelper::calculateFiles()
DiffHelper::calculateFiles()DiffHelper::getProjectDirectory()DiffHelper::getStyleSheet()INFO['type'] for renderersphpunit/phpunit 7.5DiffHelper::getTemplatesInfo() and DiffHelper::getStyleSheet()Fix Json renderer with empty changes.
Json renderer with empty changes.Fix squizlabs/php_codesniffer should be in require-dev.
squizlabs/php_codesniffer should be in require-dev.Fix AbstractHtml::expandTabs() $tabSize undeclared.
AbstractHtml::expandTabs() $tabSize undeclared.OP_EQ, it still may be $old !== $new.example/old_file.txt and the new one.The following APIs have been deprecated and will be removed in v5.
The following APIs have been deprecated and will be removed in v5.
Diff::setA() becomes Diff::setOld().Diff::setB() becomes Diff::setNew().Diff::setAB() becomes Diff::setOldNew().Diff::getA() becomes Diff::getOld().Diff::getB() becomes Diff::getNew().Fix potential boundary error in Diff::getText(). Both $start and $end could be negative.
Diff::getText().
Both $start and $end could be negative.Fix Diff::getText() when $end is null.
Diff::getText() when $end is null.Update jfcherng/php-sequence-matcher ^2.0
jfcherng/php-sequence-matcher ^2.0Fix HTML renderer should not emphasize inserted/deleted lines.
Fix HTML renderer should not emphasize inserted/deleted lines.
It looks like the following screenshot now. Line 3 (new) and 11 (old) are no longer wholly emphasized.
Fix HTML special chars in JSON renderer should be escaped.
Allow HTML renderer option tabSize to be < 0, which means do not convert tab into spaces. In this case, you must add your own CSS to visualize tabs in
tabSize to be < 0, which means do not convert tab into spaces. In this case, you must add your own CSS to visualize tabs in HTML.Move factory classes to Jfcherng\Diff\Factory\
Jfcherng\Diff\Factory\ReservedConstantInterface into RendererConstantAdd final keyword to non-inherited classes.
final keyword to non-inherited classes.See https://github.com/jfcherng/php-diff/blob/v4/UPGRADING_v4.md for upgrading.
Use JSON format language files.
Use JSON format language files.
Doing something like require "{$language}.php" is potentially dangerous if the languages/ folder is written with some malicious PHP scripts.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.