2017 © Pedro Peláez
 

library finediff

PHP implementation of a Fine granularity Diff engine

image

cogpowered/finediff

PHP implementation of a Fine granularity Diff engine

  • Monday, May 19, 2014
  • by rcrowe
  • Repository
  • 10 Watchers
  • 101 Stars
  • 1,188,625 Installations
  • PHP
  • 24 Dependents
  • 0 Suggesters
  • 18 Forks
  • 6 Open issues
  • 5 Versions
  • 11 % Grown

The README.md

** Project archived: Use https://github.com/d4h/php-finediff **, (*1)

FineDiff

Originally written by Raymond Hill (https://github.com/gorhill/PHP-FineDiff) FineDiff has been tweaked to bring it up to date with the modern world. That means documented, nicely formatted, tested code that can be easily extended., (*2)

Build Status, (*3)

Installation

Composer, (*4)

The preferred way of using FineDiff is through Composer., (*5)

Add the following to your composer.json file:, (*6)

{
    "require": {
        "cogpowered/finediff": "0.3.*"
    }
}

Upgrading

0.3.x introduces a backwards incompatible version, so if you have stored opcodes do not upgrade!, (*7)

0.3.x fixes a double encoding issue that generates a longer opcode than is needed., (*8)

Usage

Render HTML, (*9)

Render as HTML the difference between two strings:, (*10)

$diff = new cogpowered\FineDiff\Diff;
echo $diff->render('string one', 'string two');

This would then output:, (*11)

string <ins>tw</ins>o<del>ne</del>

You could change the granularity to cogpowered\FineDiff\Granularity\Word so the output is:, (*12)

string <del>one</del><ins>two</ins>

You do this by passing it into the Diff constructor:, (*13)

$granularity = new cogpowered\FineDiff\Granularity\Word;
$diff        = new cogpowered\FineDiff\Diff($granularity);

Grab opcode instructions, (*14)

Opcode instructions are what tell FineDiff how to change one string into another., (*15)

$diff = new cogpowered\FineDiff\Diff;
echo $diff->getOpcodes('string one', 'string two');

This would then output:, (*16)

c7d3i3:two

Render text using the opcodes:, (*17)

$render = new cogpowered\FineDiff\Render\Text;
echo $render->process('string one', 'c7d3i3:two');

Would output:, (*18)

string two

Same with HTML:, (*19)

$render = new cogpowered\FineDiff\Render\Html;
echo $render->process('string one', 'c7d3i3:two');

License

Copyright (c) 2011 Raymond Hill (http://raymondhill.net/blog/?p=441) Copyright (c) 2013 Rob Crowe (http://cogpowered.com), (*20)

Licensed under The MIT License, (*21)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:, (*22)

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*23)

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE., (*24)

The Versions

19/05 2014

dev-master

9999999-dev https://github.com/cogpowered/FineDiff

PHP implementation of a Fine granularity Diff engine

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

text diff string finediff opcode

19/05 2014

0.3.1

0.3.1.0 https://github.com/cogpowered/FineDiff

PHP implementation of a Fine granularity Diff engine

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

text diff string finediff opcode

19/05 2014

0.2.1

0.2.1.0 https://github.com/cogpowered/FineDiff

PHP implementation of a Fine granularity Diff engine

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

text diff string finediff opcode

19/05 2014

0.2.0

0.2.0.0 https://github.com/cogpowered/FineDiff

PHP implementation of a Fine granularity Diff engine

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

text diff string finediff opcode

14/03 2013

0.0.1

0.0.1.0 https://github.com/cogpowered/FineDiff

PHP implementation of a Fine granularity Diff engine

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

text diff string finediff opcode