czim/laravel-modelcomparer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

czim/laravel-modelcomparer

Composer 安装命令:

composer require czim/laravel-modelcomparer

包简介

Performs a deep-nested comparison of a model's before/after state.

README 文档

README

Latest Version on Packagist Software License Build Status

This model comparer is a tool to make it easy to collect, log and report changes made to Eloquent models and their relations.

It's easy enough to compare model attributes before and after (or using getDirty(), during) updates for a single Eloquent model. Unfortunately, it is arduous to track updates while updating deeply nested relational model structures.

With this package, it's as simple as loading in the model before making changes, then loading it in again after. The comparer instance tracks the changes and offers the means to create concise changelogs.

Version Compatibility

Laravel Package PHP Version
5.3 and older 0.9
5.4 to 5.7 1.4
5.8 1.5
5.8, 6.0+ 2.0
9.0+ 3.0 8.1+

Install

Via Composer

$ composer require czim/laravel-modelcomparer

If you're not using auto-discovery (or are installing a version older than 3.0), add the service provider in your config/app.php config.

    Czim\ModelComparer\ModelComparerServiceProvider::class,

Usage

  1. Initialize a comparer instance
  2. Before making changes, set the before state on the comparer by passing in the model
  3. Make your changes to anything related to the model
  4. Run the comparison by passing in the model again

The result is an comparison information object that stores all the changes and offers means for easy logging.

To Do

  • Add singleton with facade for easy tracking of changes

    • would use the model's class & key to keep track of before states and allow setting after states
    • might even be done using an observer pattern
    • note: not recommended for long running processes, unless cleanup methods are used to keep memory load small
  • Better change tracking for related models

    • Track before state index by model class & key in the comparer
      • And, singleton should delegate this to currently active comparers
    • Track changes of a model when it is still via-via related before AND after (but for a different intermediary relation)
    • Allow manually 'loading in' before state for a to-be related model

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

czim/laravel-modelcomparer 适用场景与选型建议

czim/laravel-modelcomparer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.63k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2017 年 01 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「log」 「model」 「eloquent」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 czim/laravel-modelcomparer 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 4.63k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 20
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-29