承接 xaerobiont/transfer-container 相关项目开发

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

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

xaerobiont/transfer-container

最新稳定版本:3.0.0

Composer 安装命令:

composer require xaerobiont/transfer-container

包简介

README 文档

README

PHP container for transferring DTO between services

Latest Stable Version Total Downloads

Goals

  • Allows to transfer different DTOs into single package
  • Provides mapping mechanism. I.e. when sender and receiver has different DTO namespace or even classes
  • Compress data packs
  • Very simple, lightweight and vendor-independent

Installation

{
  "require": {
    "xaerobiont/transfer-container": "^2"
  }
}

Usage

For more detailed usage examples see /tests

use Xaerobiont\TransferContainer\Transferable;
use Xaerobiont\TransferContainer\TransferContainer;

class MyDTO implements Transferable {}
class YourDTO implements Transferable {}
class ThemDTO implements Transferable {}

$package = [];
for ($i = 1; $i <= 100; $i++) {
    $package[] = new MyDTO();
    $package[] = new YourDTO();
    $package[] = new ThemDTO();
}

$container = new TransferContainer();
$container->put($package);

$transfer = $container->pack();
$container->clear();

// receiver side
$map = [
    YourDTO::class => OtherDTO::class
];
foreach (TransferContainer::unpack($transfer, $map) as $item) {
    // $item is MyDTO/OtherDTO/ThemDTO object
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-18