承接 cpsit/migrator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

cpsit/migrator

Composer 安装命令:

composer require cpsit/migrator

包简介

Composer package for migrating files with a calculated diff

README 文档

README

Screenshot

Migrator

Coverage Tests CGL Latest Stable Version Total Downloads License

📦 Packagist | 💾 Repository | 🐛 Issue tracker

A PHP library to perform migrations of files with a calculated diff between two code bases using three-way merge. Uses the cypresslab/gitelephant package for any Git operations and provides an interface for custom differ implementations.

🚀 Features

  • Automatic file content migration
  • Various implementations for source and target code base
  • Interface for custom differ implementations

🔥 Installation

composer require cpsit/migrator

⚡ Usage

Command-line

vendor/bin/migrator [options] <base-directory> <source-directory> <target-directory>

Available options:

  • --dry-run does not perform migrations, but only calculates and shows diff between code bases
  • --verbose shows the calculated diff (implicitly enabled with --dry-run)

PHP

use CPSIT\Migrator\Diff;
use CPSIT\Migrator\Formatter;
use CPSIT\Migrator\Migrator;
use CPSIT\Migrator\Resource;

// Base contains all files that should be migrated
$base = new Resource\Collector\DirectoryCollector('/path/to/base/directory');

// Source and target define the code bases
// that are used to generate a diff
$source = new Resource\Collector\DirectoryCollector('/path/to/old/revision/files');
$target = new Resource\Collector\DirectoryCollector('/path/to/current/revision/files');

// Decide whether to actually perform migrations
// or just calculate a diff between the code bases
$performMigrations = true;

// Create differ, migrator and formatter
$differ = new Diff\Differ\GitDiffer();
$migrator = new Migrator($differ, $performMigrations);
$formatter = new Formatter\TextFormatter();

// Migrate files in your base directory
$diffResult = $migrator->migrate($source, $target, $base);

// Format diff
echo $formatter->format($diffResult);

🎢 Architecture

Lifecycle

In order to generate a diff between two code bases, you must provide two collections of resources. This, for example, can be a directory with template files of a previous revision compared to a directory with template files of a current revision. Additionally, you must provide a base directory containing all files to be migrated.

The migration is calculated by a differ. It will generate and apply a diff between both code bases and the provided base files using the three-way merge strategy.

Resource

All relevant code bases (source and target) must be represented by a Resource\Collector\CollectorInterface. The following implementations are currently available:

Differ

Diffs are calculated by an implementation of Diff\Differ\Differ. The following implementations are currently available:

Formatter

Formatters can be used to properly display a calculated Diff\DiffResult. Each formatter implements Formatter\Formatter. The following implementations are currently available:

  • CliFormatter is used on command line. It displays the calculated diff with ANSI colors, targeting Symfony's console output.
  • TextFormatter can be used in other contexts than command line, e.g. to properly display the calculated diff in case ANSI colors are not available.

🧑‍💻 Contributing

Please have a look at CONTRIBUTING.md.

⭐ License

This project is licensed under GNU General Public License 3.0 (or later).

cpsit/migrator 适用场景与选型建议

cpsit/migrator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37 次下载、GitHub Stars 达 3, 最近一次更新时间为 2023 年 03 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 cpsit/migrator 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 5
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2023-03-09