定制 decatur-vote/diffs-db 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

decatur-vote/diffs-db

Composer 安装命令:

composer require decatur-vote/diffs-db

包简介

A library to store text diffs in a db & provide convenience utilities on top of decatur-vote/text-diff

README 文档

README

Diffs Db

A simple database library for storing diffs and rewinding to previous versions (or fast forwarding FROM old version).

Uses decatur-vote/text-diff for generating diffs and taeluf/big-db for database migrations, orm, and stored queries.

For additional database & diff functionality, see the above libraries. DiffsDb is a very simple wrapper around them.

Status

Probably ready to use? Not a lot of features (it's supposed to be quite simple). Tests passing (though, tests are not very thorough). Has not been tested in the wild.

Installation

composer require decatur-vote/diffs-db v1.0.x-dev   

or in your composer.json

{"require":{ "decatur-vote/diffs-db": "v1.0.x-dev"}}  

Documentation

  • See Usage below for most use cases.
  • TextDiff orm class
  • DiffsDb base class for the database layer (for BigDb). Contains the helper functions store_diff, and forward/backward.
  • text_diffs.sql the sql used within this library
  • Text Diff Library - for any manual text diff management
  • BigDb Library - for more info about working with the database. You can always just use your PDO instance, too.

Initialize the Database

Run this command in your CLI

bin/diffs-db create-db -pdo path/to/pdo.php  

You MUST create the file path/to/pdo.php and have it return a PDO instance. The table will be created with that instance.

Usage

This is basically everything.

<?php  
$pdo = new \PDO(...);  
$diffDb = new \DecaturVote\DiffDb($pdo);  
$diffDb->migrate(0,1); // initialize the database  
  
// these 3 args are your responsibility, and can be used in your own custom queries however you wish.  
$uuid = uniqid(); // up to 64 chars  
$permission = 'public';  // up to 32 chars  
$extra = 'Descriptive text, not intended for machine use. permission is intended for machine uses'; // up to 256 chars  
  
// store_diff() returns a \DecaturVote\DiffDb\TextDiff object & INSERTs into database  
$diff1 = $diffDb->store_diff('original', 'first change', $uuid, $permission, $extra);  
$diff2 = $diffDb->store_diff('first change', "first change\nsecond change", $uuid, $permission, $extra);  
$diff3 = $diffDb->store_diff("first change\nsecond change",  "third change", $uuid, 'private', $extra);  
  
  
// get all diffs for the uuid.  
$diffs = $diffDb->get_diffs($uuid);  
// $diffDb->get_diffs($uuid, 'public'); # if you only want public diffs - Useful for displaying diffs to end-users, bad for converting text.  
  
// get your original text  
$original = $diffDb->backward("third change", $diffs);  
  
// use the original text + diffs to get the latest text  
$latest = $diffDb->forward('original', $diffs);  
  
// Only go back by one diff  
$back_one = $diffDb->backward("third change", array_slice($diffs,-1));  

You can also use the TextDiff orm as you please. It's basically just properties for each database column.

Development Notes

  • Uses taeluf/tester. run tests with phptest
  • Uses taeluf/code-scrawl. Generate updated documentation with vendor/bin/scrawl. Edit docs in .docsrc, NOT in docs/ or the root README.md

decatur-vote/diffs-db 适用场景与选型建议

decatur-vote/diffs-db 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 05 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 decatur-vote/diffs-db 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 decatur-vote/diffs-db 我们能提供哪些服务?
定制开发 / 二次开发

基于 decatur-vote/diffs-db 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 14
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-26