Download the PHP package caxy/php-htmldiff without Composer
On this page you can find all versions of the php package caxy/php-htmldiff. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download caxy/php-htmldiff
More information about caxy/php-htmldiff
Files in caxy/php-htmldiff
Package php-htmldiff
Short Description A library for comparing two HTML files/snippets and highlighting the differences using simple HTML.
License GPL-2.0
Homepage https://github.com/caxy/php-htmldiff
Rated 5.00 based on 1 reviews
Informations about the package php-htmldiff
php-htmldiff
php-htmldiff is a library for comparing two HTML files/snippets and highlighting the differences using simple HTML.
This HTML Diff implementation was forked from rashid2538/php-htmldiff and has been modified with new features, bug fixes, and enhancements to the original code.
For more information on these modifications, read the differences from rashid2538/php-htmldiff or view the CHANGELOG.
Demo
https://php-htmldiff.caxy.com/
Installation
The recommended way to install php-htmldiff is through Composer. Require the caxy/php-htmldiff package by running following command:
This will resolve the latest stable version.
Otherwise, install the library and setup the autoloader yourself.
Working with Symfony
If you are using Symfony, you can use the caxy/HtmlDiffBundle to make life easy!
Usage
CSS Example
See https://github.com/caxy/php-htmldiff/blob/master/demo/codes.css for starter CSS you can use for displaying the HTML diff output.
Configuration
The configuration for HtmlDiff is contained in the Caxy\HtmlDiff\HtmlDiffConfig
class.
There are two ways to set the configuration:
- Configure an Existing HtmlDiff Object
- Create and Use a HtmlDiffConfig Object
Configure an Existing HtmlDiff Object
When a new HtmlDiff
object is created, it creates a HtmlDiffConfig
object with the default configuration.
You can change the configuration using setters on the object:
Create and Use a HtmlDiffConfig Object
You can also set the configuration by creating an instance of
Caxy\HtmlDiff\HtmlDiffConfig
and using it when creating a new HtmlDiff
object using HtmlDiff::create
.
This is useful when creating more than one instance of HtmlDiff
:
Full Configuration with Defaults:
Contributing
See CONTRIBUTING file.
Contributor Code of Conduct
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See CODE_OF_CONDUCT file.
Credits
- SavageTiger for contributing many improvements and fixes to caxy/php-htmldiff!
- rashid2538 for the port to PHP and the base for our project: rashid2538/php-htmldiff
- willdurand for an excellent post on open sourcing libraries. Much of this documentation is based off of the examples in the post.
Did we miss anyone? If we did, let us know or put in a pull request!
License
php-htmldiff is available under GNU General Public License, version 2. See the LICENSE file for details.
TODO
- Tests, tests, and more tests! (mostly unit tests) - need more tests before we can major refactoring / cleanup for a v1 release
- Add documentation for setting up a cache provider (doctrine cache)
- Maybe add abstraction layer for cache + adapter for doctrine cache
- Make HTML Purifier an optional dependency - possibly use abstraction layer for purifiers so alternatives could be used (or none at all for performance)
- Expose configuration for HTML Purifier (used in table diffing) - currently only cache dir is configurable through HtmlDiffConfig object
- Performance improvements (we have 1 benchmark test, we should probably get more)
- Algorithm improvements - trimming alike text at start and ends, store nested diff results in memory to re-use (like we do w/ caching)
- Benchmark using DOMDocument vs. alternatives vs. string parsing
- Consider not using string parsing for HtmlDiff in order to avoid having to create many DOMDocument instances in ListDiff and TableDiff
- Benchmarking
- Refactoring (but... tests first)
- Overall design/architecture improvements
- API improvements so a new HtmlDiff isn't required for each new diff (especially so that configuration can be re-used)
- Split demo application to separate repository
- Add documentation on alternative htmldiff engines and perhaps some comparisons
All versions of php-htmldiff with dependencies
ezyang/htmlpurifier Version ^4.7
ext-dom Version *
ext-mbstring Version *