greywolfs / fine-diff-bundle
FineDiff Symfony3 Bundle implementation
Installs: 1 346
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 2
Type:symfony-bundle
Requires
- php: ^5.4 || ^7.0
- symfony/framework-bundle: ~3.0
- twig/extensions: ^1.5
Requires (Dev)
- phpunit/phpunit: ~4.4
README
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
Installation
Add to composer
Run in command line:
$ composer require greywolfs/fine-diff-bundle
Or add with hand to composer.json:
"require": { "greywolfs/fine-diff-bundle": "~1.10" }
Register the bundle
Add the app
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Greywolfs\FineDiffBundle\GreywolfsPHPFineDiffBundle(), ); }
Configure
Optional. You can change the default granularity.
# app/config/config.yml greywolfs_fine_diff: default_granularity: character # This is the default granularity. Alternatives: 'word', 'sentence' and 'paragraph'
Usage
There are two twig function:
renderDiff()
: compare two stringsrenderHtmlTextDiff()
: compare two strings which contain HTML tags. Remove tags withstrip_tags
before compare strings
{{ renderDiff(oldValue, newValue) }} {{ renderDiff(oldValue, newValue, 'word') }} {{ renderHtmlTextDiff(oldValue, newValue) }} {{ renderHtmlTextDiff(oldValue, newValue, 'sentence') }}