snebes/php-daisydiff

PHP DaisyDiff Port

v1.0.0 2019-01-30 23:05 UTC

This package is auto-updated.

Last update: 2024-10-11 04:34:39 UTC


README

PHP Version Latest Version Build Status Code Quality Test Coverage

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.