snebes / php-daisydiff
PHP DaisyDiff Port
Installs: 3 358
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.1.0
- ext-mbstring: *
- ext-xml: *
Requires (Dev)
- phpstan/phpstan: ^0.11.1
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2024-10-11 04:34:39 UTC
README
Daisy Diff is a PHP implementation of the Java library that diffs (compares) HTML files. It highlights added and removed words and annotates changes to the styling.
Installation
You can add this library as a local, per-project dependency to your project using Composer:
composer require snebes/php-daisydiff
Usage
The DaisyDiff
class can be used to generate a textual representation of the difference between two HTML strings:
<?php use SN\DaisyDiff\DaisyDiff; $original = '<html><body>The original document</body></html>'; $modified = '<html><body>The changed document</body></html>'; $daisyDiff = new DaisyDiff(); \printf("%s\n", $daisyDiff->diff($original, $modified));
The code above yields the output below:
<html>The <del class="diff-html-removed">original </del><ins class="diff-html-added">changed </ins>document</html>
Thanks
Many thanks to:
- Java DaisyDiff, the original Java version of the DaisyDiff library.
- gdevanla/assist from which many of the tests of this library are extracted.