Download the PHP package cogpowered/finediff without Composer
On this page you can find all versions of the php package cogpowered/finediff. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cogpowered/finediff
More information about cogpowered/finediff
Files in cogpowered/finediff
Package finediff
Short Description PHP implementation of a Fine granularity Diff engine
License MIT
Homepage https://github.com/cogpowered/FineDiff
Informations about the package finediff
Project archived: Use https://github.com/d4h/php-finediff
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.
Installation
Composer
The preferred way of using FineDiff is through Composer.
Add the following to your composer.json file:
Upgrading
0.3.x introduces a backwards incompatible version, so if you have stored opcodes do not upgrade!
0.3.x
fixes a double encoding issue that generates a longer opcode than is needed.
Usage
Render HTML
Render as HTML the difference between two strings:
This would then output:
You could change the granularity to cogpowered\FineDiff\Granularity\Word
so the output is:
You do this by passing it into the Diff constructor:
Grab opcode instructions
Opcode instructions are what tell FineDiff how to change one string into another.
This would then output:
Render text using the opcodes:
Would output:
Same with HTML:
License
Copyright (c) 2011 Raymond Hill (http://raymondhill.net/blog/?p=441) Copyright (c) 2013 Rob Crowe (http://cogpowered.com)
Licensed under The MIT License
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.