承接 remi-san/serializer 相关项目开发

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

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

remi-san/serializer

Composer 安装命令:

composer require remi-san/serializer

包简介

A universal, config-less PHP serializer for all purpose.

README 文档

README

Author Build Status Quality Score Software License Packagist Version Coverage Status SensioLabsInsight

Based on GeneratedHydrator, it serializes recursively, adding metadata to the generated array in order to be able to deserialize an object without knowing its type beforehand.

Installation

Serializer can be found on Packagist. The recommended way to install Serializer is through composer.

Run the following on the command line:

composer require remi-san/serializer=@stable

And install dependencies:

composer install

Usage

$classMapper = new RemiSan\Serializer\Mapper\DefaultMapper(
    new RemiSan\Serializer\NameExtractor\DefaultNameExtractor()
);
$classMapper->register(RemiSan\Serializer\Sample\MySampleClass::class);

$serializer = new RemiSan\Serializer\Serializer(
    $classMapper,
    new RemiSan\Serializer\Hydrator\HydratorFactory(__DIR__ . '/proxies', true),
    new RemiSan\Serializer\Formatter\FlatFormatter(),
    new Doctrine\Instantiator\Instantiator()
);

$object = new MySampleClass(new MySampleClass());
$serialized = $serializer->serialize($object);
$deserialized = $serializer->deserialize($serialized);

Command usage

When installing through composer, a CLI command is also made available (in vendor/bin/ or bin/ according to your composer.json):

bin/serializer generate:cache <cache-path> <fully-qualified-class-name>

It will write the cached version of the hydrator for the requested class in the path you provided.

You'll have to generate cached files for all your serializable classes when running in production (with the generateProxies option of the HydratorFactory set to `false).

You'll also have to make the autoloader aware of your hydrators by adding the following to your composer.json:

{
    "autoload": {
        "classmap": [
            "/path/to/cache-dir"
        ]
    }
}

Details

To be instantiated, the Serializer needs a SerializableClassMapper, a HydratorFactory, a DataFormatter and an Instantiator.

SerializableClassMapper is used to register the classes the serializer will be able to (de-)serialize. It needs a SerializableClassNameExtractor which will be able to normalize the name of the class the way you want it.

HydratorFactory will retrieve the hydrators needed to deserialize data. It needs the path to the cache directory and whether or not, it should generate the proxies on runtime.

DataFormatter will provide the way the serialized array will be formatted (provided implementations allow it to format it as a 2-level array or a flat one with a _metadata key).

Instantiator will allow to instantiate an object without the constructor based on the fully qualified class name of the requested object.

remi-san/serializer 适用场景与选型建议

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

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

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

围绕 remi-san/serializer 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-03-07