PHPackages                             duncan3dc/serial - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. duncan3dc/serial

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

duncan3dc/serial
================

Consistent serialization helpers for multiple backends

2.0.0(4y ago)0386.4k↓33%23Apache-2.0PHPPHP ^7.4 || ^8.0

Since Oct 13Pushed 4y ago1 watchersCompare

[ Source](https://github.com/duncan3dc/serial)[ Packagist](https://packagist.org/packages/duncan3dc/serial)[ Docs](https://github.com/duncan3dc/serial)[ RSS](/packages/duncan3dc-serial/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (14)Used By (3)

serial
======

[](#serial)

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

[![release](https://camo.githubusercontent.com/382748d7f2db871a3d6388d5d076c21d4a0fb1292fdfd79ab787880437a467df/68747470733a2f2f706f7365722e707567782e6f72672f64756e63616e3364632f73657269616c2f76657273696f6e2e737667)](https://packagist.org/packages/duncan3dc/serial)[![build](https://github.com/duncan3dc/serial/workflows/buildcheck/badge.svg?branch=master)](https://github.com/duncan3dc/serial/workflows/buildcheck/badge.svg?branch=master)\]() [![coverage](https://camo.githubusercontent.com/b2de1ea1f82211a1a16240c268abbbc02725e2289511dedf28f193c1b7592102/68747470733a2f2f636f6465636f762e696f2f67682f64756e63616e3364632f73657269616c2f67726170682f62616467652e737667)](https://codecov.io/gh/duncan3dc/serial)

Available Classes
=================

[](#available-classes)

- Json (using the native json\_\* functions)
- Yaml (using the Symfony Yaml component)
- Php (using the native serialize/unserialize functions)

Interface
=========

[](#interface)

All serialization classes implement the interface [duncan3dc\\Serial\\SerialInterface](src/SerialInterface.php)

Examples
========

[](#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
===========

[](#arrayobject)

The `decode()` and `decodeFromFile()` methods return a custom [ArrayObject](http://php.net/manual/en/class.arrayobject.php).

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();
```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 98.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~354 days

Recently: every ~590 days

Total

8

Last Release

1759d ago

Major Versions

0.4.0 → 1.0.02016-08-17

1.2.0 → 2.0.02021-07-24

PHP version history (5 changes)0.1.0PHP &gt;=5.4.0

1.0.0PHP &gt;=5.6.0

1.1.0PHP ^5.6|^7.0

1.2.0PHP ^7.1

2.0.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/11dc66042513f11d1c99b1e6763f25dca84a3ff31cdbea3972b9b804a3d3d5e9?d=identicon)[duncan3dc](/maintainers/duncan3dc)

---

Top Contributors

[![duncan3dc](https://avatars.githubusercontent.com/u/546811?v=4)](https://github.com/duncan3dc "duncan3dc (66 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

jsonphpserializeryamljsonyamlserializerserializationserialisationserialiser

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/duncan3dc-serial/health.svg)

```
[![Health](https://phpackages.com/badges/duncan3dc-serial/health.svg)](https://phpackages.com/packages/duncan3dc-serial)
```

###  Alternatives

[thunderer/serializard

Flexible serializer

2767.3k1](/packages/thunderer-serializard)[opensoft/simple-serializer

Simple Serializer

1914.2k1](/packages/opensoft-simple-serializer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
