gathercontent/htmldiff
Composer 安装命令:
composer require gathercontent/htmldiff
包简介
Compare two HTML strings
README 文档
README
Compare two HTML strings. This library converts HTML into a form that can be diffed using the algorithm found in Git or Linux (comparing entire lines of code) to achieve greater accuracy, then decodes it back into a valid HTML.
Requirements
- PHP 5.3.0 or later
- Tidy extension for PHP
Installation
Add Htmldiff to your composer.json file:
"require": { "gathercontent/htmldiff": "0.2.*" }
Get composer to install the package:
$ composer update gathercontent/htmldiff
Usage
The input is going to be parsed by Tidy before diffing. Here's a few examples:
$old = '<span>This is a string</span>'; $new = '<span>This is a text</span>'; $htmldiff = new Htmldiff; $result = $htmldiff->diff($old, $new); // result: <span>This is a <del>string</del><ins>text</ins></span>
$old = '<p>Hello world, how do you do</p>'; $new = '<p>Hello world, how do <strong>you</strong> do</p>'; $htmldiff = new Htmldiff; $result = $htmldiff->diff($old, $new); // result: <p>Hello world, how do <del>you</del><strong><ins>you</ins></strong> do</p>
$old = '<p>Hello world</p><p>How do you do</p>'; $new = '<p>Hello world</p><ul><li>first point</li><li>second point</li></ul><p>How do you do</p>'; $htmldiff = new Htmldiff; $result = $htmldiff->diff($old, $new); // result: <p>Hello world</p><ul><li><ins>first point</ins></li><li><ins>second point</ins></li></ul><p>How do you do</p>
Testing
Run unit tests:
$ ./vendor/bin/phpunit
Test compliance with PSR2 coding style guide:
$ ./vendor/bin/phpcs --standard=PSR2 ./src
Licence
The MIT License (MIT) - see README.md
gathercontent/htmldiff 适用场景与选型建议
gathercontent/htmldiff 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 288.86k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2014 年 07 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 gathercontent/htmldiff 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gathercontent/htmldiff 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 288.86k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 17
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-07-23