Original fine diff library:
- https://github.com/webtown-php/fine-diff-bundle
- https://github.com/gorhill/PHP-FineDiff
- http://www.raymondhill.net/finediff/viewdiff-ex.php
Run in command line:
$ composer require AlDaFlux/fine-diff-bundleOr add with hand to composer.json:
"require": {
"AlDaFlux/fine-diff-bundle": "~1.10"
}Add the app
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new AlDaFlux\FineDiffBundle\AlDaFluxPHPFineDiffBundle(),
);
}Optional. You can change the default granularity.
# app/config/config.yml
AlDaFlux_fine_diff:
default_granularity: character # This is the default granularity. Alternatives: 'word', 'sentence' and 'paragraph'There are two twig function:
renderDiff(): compare two stringsrenderHtmlTextDiff(): compare two strings which contain HTML tags. Remove tags withstrip_tagsbefore compare strings
{{ renderDiff(oldValue, newValue) }}
{{ renderDiff(oldValue, newValue, 'word') }}
{{ renderHtmlTextDiff(oldValue, newValue) }}
{{ renderHtmlTextDiff(oldValue, newValue, 'sentence') }}