承接 ayeo/pinkman 相关项目开发

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

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

ayeo/pinkman

Composer 安装命令:

composer require ayeo/pinkman

包简介

Simple serialization/deserialization util

README 文档

README

Build Status Coverage Software License

Notice: Pinkman is still not at stable stage yet. Use carefully.

Pinkman is super happy to convert any object to an array for you. It also here to reconsistute the object from pure array data. At my company we happily use Pinkman to help us store our aggregates into the database. In case you struggle with CQRS approachat your side you may find him usefull as well. Think of Pinkman as of your personal laboratory assistant. He can't wait to help you rule the world tonignt.

Motivation

Build-in php serialize/unserialize functions works fine until you are not about to change your objects. Then it becomes impossibne to unserialize prevoisly serialized object. I have found few similar tools on github but wasn't happy with any mainly because of heavy config.

Install

composer require ayeo/pinkman:0.1.0

Core features

  • working with privete/proteced properties
  • handling nested objects
  • handling recurrent nesting
  • handling nested arrays/collectoins

The simplest possible scenario example

Serialization

Consider the simple flat object to get the point:

class Address
{
    private $street;
    private $buildingNumber;
    private $apartamentNumber;
    private $postalCode;
    private $town;
    
    public function __construct(
        string $street,
        string $buildingNumber,
        string $apartamentNumver,
        string $postalCode,
        string $town,
        string $countryCode
    ) {
        //...
    }
}

Converting to an array is straitforward

use Ayeo/Pinkman/Pinkaman;

$address = new Address('Thomas Edisson Av', '34a', '11', 'NG10-32Q', 'Nottingham', 'UK');
$pinkman = new Pinkman()
$pureData = $pinkman->distill($address);

Data array looks like this:

$pureData = [
    'street' => 'Thomas Edisson Av',
    'buildingNumber' => '34a',
    'apartamentNumber' => '11',
    'postalCode' => 'NG10-34Q',
    'town' => 'Nottingham',
    'countryCode' => 'UK'
];

It is nothing more than mapping object structure to an array. But is start shinning with more complex structures.

Deserialization

As you have probably noticed the output data is an array consisting of raw data. To reconstitute living object you need to provide adequate config. In our simple scenario looks like this:

$config = [
    'class' => Address::class
];
$object = $pinkman->hydrate($pureData, $config);

More elaborate and complex examples are comming your way

ayeo/pinkman 适用场景与选型建议

ayeo/pinkman 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.99k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 10 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-26