承接 danog/magicalserializer 相关项目开发

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

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

danog/magicalserializer

Composer 安装命令:

composer require danog/magicalserializer

包简介

Serialize Volatile, Threaded or any other internal PHP class!

README 文档

README

Licensed under AGLPV3, created by Daniil Gentili (https://daniil.it).

This library allows you to serialize classes that extend pthreads's Volatile or Threaded classes, or any other internal class with a custom serializer.

It also provides reverse and forward compatibility between old serializations, where your objects do not yet extend Threaded/Volatile, and new serializations, where they do extend them.

Install it using composer, the package name is danog/magicalserializer.

Usage of this library is extremely simple, here are a few examples (see a.php and b.php for more):

<?php

class a
{
    public function __construct() {
        var_dump("Constructed!");
        $this->a = 'pony';
    }
    public function __wakeup() {
        var_dump($this->a);
    }
}
$a = new a;
file_put_contents('test', serialize($a));

As you can see, here a does not extend any class, and we are serializing an instance of it to the file test. This example also prints Constructed!, since the constructor function, __magic_construct, is called.

<?php

class a extends \Volatile
{
    use \danog\Serializable;
    public function __magic_construct() {
        var_dump("Constructed!");
        $this->a = 'pony';
    }
    public function __wakeup() {
        var_dump($this->a);
    }
}
$a = \danog\Serialization::unserialize(file_get_contents('test'));
var_dump($a);
$othera = new a;

Here we must simply include the trait \danog\Serializable to make the class serializable.
This will deserialize correctly the contents of test, recreating the instance of a, with the only difference that now it will be thread safe.
Of course, the wakeup function will be called, so pony will be printed.
You may have noticed that the construct function is now called __magic_construct instead of __construct: this is a required change, or else this library will not work.
Of course, when a will be instantiated, the constructor function will be called anyway (and you'll see the message Constructed! pop up).

If you try to serialize (using \danog\Serialization::serialize) either $a or $othera and deserialize it from the first script (where a does not extend any other class), you will find that it will be deserialized correctly.

danog/magicalserializer 适用场景与选型建议

danog/magicalserializer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 538.88k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2017 年 04 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: AGPL-3.0-only
  • 更新时间: 2017-04-30