h4kuna/serialize-polyfill 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

h4kuna/serialize-polyfill

最新稳定版本:v0.2.5

Composer 安装命令:

composer require h4kuna/serialize-polyfill

包简介

Provide methods for serialization and use igbinary if is available.

README 文档

README

Downloads this Month Latest stable

In your project are available two new methods.

  • h4kuna\Serialize\Serialize::encode()
  • h4kuna\Serialize\Serialize::decode()

If you enable igbinary extension, then automatic use Driver\IgBinary. Or you can define own implmentation by Driver interface.

Example why use Serialize class

In many use cases is igbinary faster. Anybody use in third party library h4kuna\Serialize\Serialize::encode/decode. If you enable igbinary and for this third party case you want to disable and to use standard serialization. See example.

External library in vendor

namespace Com\Example; use h4kuna\Serialize\Serialize; class Foo implements \Serializable { public function serialize(): ?string { return Serialize::encode($this, __CLASS__); } public function unserialize(string $data): void { Serialize::decode($data, __CLASS__); // do anything } }

Enable standard serialization for class above.

use h4kuna\Serialize\Driver; use h4kuna\Serialize\Serialize; require_once __DIR__ . '/vendor/autoload.php'; Serialize::setUp(Driver\IgBinary::class, [ Com\Example\Foo::class => Driver\Php::class // only for Com\Example\Foo use case ]); 

Compatibility

You are using php serialize and you want to use igbinary. You can enable igbinaty on fly and old serialized data will be decoded by old php serialize.

Support compatibility, if you have serialized data by php serialize, then you can decode by IgBinary::decode() and vice versa.

Enable igbinary

  1. Install igbinary extension
require __DIR__ . '/vendor/autoload.php'; \h4kuna\Serialize\Serialize::setUp(IgBinary::class);

Works!

Disable igbinary

  1. set Php driver after vendor/autoload.php
require __DIR__ . '/vendor/autoload.php'; // \h4kuna\Serialize\Serialize::setUp(IgBinary::class); remove
  1. wait if your all data will be decoded
  2. uninstall igbinary extension

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固