承接 duncan3dc/serial 相关项目开发

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

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

duncan3dc/serial

最新稳定版本:2.0.0

Composer 安装命令:

composer require duncan3dc/serial

包简介

Consistent serialization helpers for multiple backends

README 文档

README

A collection of PHP serialization helpers with a consistent interface for each.

release build](https://github.com/duncan3dc/serial/actions?query=branch%3Amaster+workflow%3Abuildcheck) coverage

Available Classes

  • Json (using the native json_* functions)
  • Yaml (using the Symfony Yaml component)
  • Php (using the native serialize/unserialize functions)

Interface

All serialization classes implement the interface duncan3dc\Serial\SerialInterface

Examples

Convert array data to string format

use duncan3dc\Serial\Json;
$data = BusinessLogic::getDataAsArray();
$json = Json::encode($data);

Convert string formatted data to an array

use duncan3dc\Serial\Yaml;
$yaml = Api::getYamlResponse($request);
$response = Yaml::decode($yaml);

Convient methods to serialize and store data on disk

use duncan3dc\Serial\Json;
$filename = "/tmp/file.json";
$data = BusinessLogic::getDataAsArray();
Json::encodeToFile($filename, $data);

Retrieve previously stored data from disk

use duncan3dc\Serial\Json;
$filename = "/tmp/file.json";
$data = Json::decodeFromFile($filename);

ArrayObject

The decode() and decodeFromFile() methods return a custom ArrayObject.

If you need a plain array you can get one like so:

$array = Json::decode($jsonString)->asArray();

There are also helper methods to convert to any of the available serialization formats.

$data = Json::decode($jsonString);
$yaml = $data->asYaml();
$json = $data->asJson();
$php = $data->asPhp();

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固