PHPackages                             meta-serializer/meta-serializer - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. meta-serializer/meta-serializer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

meta-serializer/meta-serializer
===============================

MetaSerializer php library.

2.2.7(3y ago)0183↓16.7%PHPPHP &gt;=7.1.0CI failing

Since May 27Pushed 3y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (32)Used By (0)

meta-serializer
===============

[](#meta-serializer)

[![Build Status](https://camo.githubusercontent.com/5d13d690fedeeee80d08dcd3686d0df1dd382c3e74350fc49169a05f7cb8d2ca/68747470733a2f2f7472617669732d63692e6f72672f796172333333332f6d6574612d73657269616c697a65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/yar3333/meta-serializer)[![Latest Stable Version](https://camo.githubusercontent.com/ce6098dbf0ee46db783a9871281b5c57642194b0d120ba9427a55cf6e5da962d/68747470733a2f2f706f7365722e707567782e6f72672f6d6574612d73657269616c697a65722f6d6574612d73657269616c697a65722f76657273696f6e)](https://packagist.org/packages/meta-serializer/meta-serializer)[![Total Downloads](https://camo.githubusercontent.com/c44728657aca3ddbb58d8d1ef31f3041737cb2af5bfc47d998502dea6cf684b5/68747470733a2f2f706f7365722e707567782e6f72672f6d6574612d73657269616c697a65722f6d6574612d73657269616c697a65722f646f776e6c6f616473)](https://packagist.org/packages/meta-serializer/meta-serializer)

Production ready simple and flexible PHP serializer and deserializer. Support `array`, `ArrayObject`, nested objects and associative arrays.

Install
-------

[](#install)

```
composer require meta-serializer/meta-serializer
```

Using
-----

[](#using)

Control serialization/deserialization by phpdoc @annotations or by field-related class methods. Methods have a higher priority. Class attributes for serialization/deserialization must be public.

Serializer:

- support special phpdoc annotations: `@ignore`, `@ignoreNull` and `@renameTo` (see example);
- override `onRecursiveObjectReferenceDetected` if need (throws exception by default);
- override `serializeValue` to support additional types;
- catch `MetaSerializerException` to detect deserialization errors.

Deserializer:

- use type from @var phpdoc (specify full class name with namespace like `\MyNamespace\MyNestedClass` or `\DateTime`);
- support special phpdoc annotations: `@ignore`, `@optional` and `@sourceName` (see example);
- override `onNoValueProvided` if need (throws exception by default);
- override `onNotNullableValueIsNull` if need (throws exception by default);
- override `deserializeValueNotNullableType` to support additional types;
- `\DateTime` supported from string (in format suatable for `\DateTime` constructor) or number (unix timestamp);
- catch `MetaDeserializerException` to detect deserialization errors.

Example
-------

[](#example)

```
class MyClass
{
    /**
     * @var int|null This is a nullable integer.
     */
    public $a = 5;

    /**
     * Using field-related methods.
     */
    public $b = "str";
    protected function b__toJson(array &$data, string $prop, MetaSerializer $ser) { $data['myJsonFieldName'] = $this->b . "InJson"; }
    protected function b__fromJson(array $data, string $prop, MetaDeserializer $des) { $this->b = $data['myJsonFieldName']; }

    /**
     * Using phpdoc annotations.
     * @var string
     * @toJson_ignoreNull
     * @toJson_renameTo fieldC
     * @fromJson_optional
     * @fromJson_sourceName fieldC
     */
    public $c = "thisIsC";
}

// SERIALIZATION

$serializer = new MetaSerializer("__toJson", "toJson_");
$data = $serializer->serializeObject(new MyClass());
// data: [ "a" => 5, "myJsonFieldName" => "strInJson", "fieldC" => "thisIsC" ]

// DESERIALIZATION

$deserializer = new MetaDeserializer("__fromJson", "fromJson_");

// object will be created by deserializeObject(), so
// it must has constructor with no/default parameters
$obj = $deserializer->deserializeObject($data, MyClass::class);
// obj: MyClass { a:5, b:"strInJson", c:"thisIsC" }

// manually object creating
$obj = new MyClass();
$deserializer->deserializeObjectProperties($data, $obj);
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 87.8% 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 ~37 days

Recently: every ~155 days

Total

31

Last Release

1423d ago

Major Versions

1.1.4 → 2.0.02019-06-14

PHP version history (2 changes)1.0.0PHP &gt;=7.2.0

2.0.1PHP &gt;=7.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/62287c6031fadbee2c2b9c588d6f8f843e511bafec08e9cdbe12e0fae5a05de3?d=identicon)[yar3333](/maintainers/yar3333)

---

Top Contributors

[![yar3333](https://avatars.githubusercontent.com/u/900330?v=4)](https://github.com/yar3333 "yar3333 (43 commits)")[![Isludnikov](https://avatars.githubusercontent.com/u/29144634?v=4)](https://github.com/Isludnikov "Isludnikov (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/meta-serializer-meta-serializer/health.svg)

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

###  Alternatives

[spiral/mcp-server

Spiral bridge for MCP server

541.1k2](/packages/spiral-mcp-server)

PHPackages © 2026

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