PHPackages                             remi-san/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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. remi-san/serializer

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

remi-san/serializer
===================

A universal, config-less PHP serializer for all purpose.

v1.2.2(5y ago)314.5k↓50%2MITPHPPHP &gt;=5.5CI failing

Since Mar 7Pushed 5y ago1 watchersCompare

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

READMEChangelog (6)Dependencies (9)Versions (8)Used By (2)

Serializer
==========

[](#serializer)

[![Author](https://camo.githubusercontent.com/4488dd05eac93ae677fc802ca3f7ecdf019ffac5386384282044a33dd0858654/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d4052656d6953616e2d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/RemiSan)[![Build Status](https://camo.githubusercontent.com/ae47660505259102a74577af7ceefb98722d09d1891decfa1accddd6ac5c78c2/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f72656d692d73616e2f73657269616c697a65722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/remi-san/serializer)[![Quality Score](https://camo.githubusercontent.com/480888d98f9afb5851f10ec843782912bf2aff738ecb4581efb4a969f3af46ab/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f72656d692d73616e2f73657269616c697a65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/remi-san/serializer)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Packagist Version](https://camo.githubusercontent.com/922904f18bdf58e4eb538643eb5c520062fd5e3a456b08eca07a3284b7c5edaf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72656d692d73616e2f73657269616c697a65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/remi-san/serializer)[![Coverage Status](https://camo.githubusercontent.com/395468f7be21cd4013a23728d4b71b4ac358db32929ec173ccaf00273bd69d9b/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f72656d692d73616e2f73657269616c697a65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/remi-san/serializer/code-structure)[![SensioLabsInsight](https://camo.githubusercontent.com/2d8b794eabadf716cfda46e51e261b4b7e55797c7cfe54c8eb5e0315157da2ce/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f65663938396164662d303637642d343633302d393937392d6632376335353937343063332f736d616c6c2e706e67)](https://insight.sensiolabs.com/projects/ef989adf-067d-4630-9979-f27c559740c3)

Based on [**GeneratedHydrator**](https://github.com/Ocramius/GeneratedHydrator), it serializes recursively, adding metadata to the generated array in order to be able to deserialize an object without knowing its type beforehand.

Installation
------------

[](#installation)

**Serializer** can be found on [Packagist](https://packagist.org/packages/remi-san/serializer). The recommended way to install **Serializer** is through [composer](http://getcomposer.org).

Run the following on the command line:

```
composer require remi-san/serializer=@stable
```

And install dependencies:

```
composer install
```

Usage
-----

[](#usage)

```
$classMapper = new RemiSan\Serializer\Mapper\DefaultMapper(
    new RemiSan\Serializer\NameExtractor\DefaultNameExtractor()
);
$classMapper->register(RemiSan\Serializer\Sample\MySampleClass::class);

$serializer = new RemiSan\Serializer\Serializer(
    $classMapper,
    new RemiSan\Serializer\Hydrator\HydratorFactory(__DIR__ . '/proxies', true),
    new RemiSan\Serializer\Formatter\FlatFormatter(),
    new Doctrine\Instantiator\Instantiator()
);

$object = new MySampleClass(new MySampleClass());
$serialized = $serializer->serialize($object);
$deserialized = $serializer->deserialize($serialized);
```

Command usage
-------------

[](#command-usage)

When installing through **composer**, a **CLI command** is also made available (in `vendor/bin/` or `bin/` according to your `composer.json`):

```
bin/serializer generate:cache
```

It will write the cached version of the **hydrator** for the requested class in the path you provided.

You'll have to generate **cached files** for all your serializable classes when running in production (with the `generateProxies` option of the `HydratorFactory` set to `false).

You'll also have to make the **autoloader** aware of your **hydrators** by adding the following to your `composer.json`:

```
{
    "autoload": {
        "classmap": [
            "/path/to/cache-dir"
        ]
    }
}
```

Details
-------

[](#details)

To be instantiated, the `Serializer` needs a `SerializableClassMapper`, a `HydratorFactory`, a `DataFormatter` and an `Instantiator`.

`SerializableClassMapper` is used to register the classes the serializer will be able to (de-)serialize. It needs a `SerializableClassNameExtractor` which will be able to normalize the name of the class the way you want it.

`HydratorFactory` will retrieve the hydrators needed to deserialize data. It needs the path to the `cache directory` and whether or not, it should generate the proxies on runtime.

`DataFormatter` will provide the way the serialized array will be formatted (provided implementations allow it to format it as a 2-level array or a flat one with a `_metadata` key).

`Instantiator` will allow to instantiate an object without the constructor based on the fully qualified class name of the requested object.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~302 days

Recently: every ~452 days

Total

7

Last Release

1912d ago

Major Versions

v0.2.0 → v1.0.02016-03-12

PHP version history (3 changes)v0.1.0PHP &gt;5.3

v1.0.0PHP &gt;5.5

v1.2.1PHP &gt;=5.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/9999746240ba052017622ecdce5ac44e6a43db5f38084ff7644691207925c043?d=identicon)[remi-san](/maintainers/remi-san)

---

Top Contributors

[![remi-san](https://avatars.githubusercontent.com/u/5213540?v=4)](https://github.com/remi-san "remi-san (32 commits)")

---

Tags

phpserializer

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[goetas-webservices/xsd2php

Convert XSD (XML Schema) definitions into PHP classes and JMS metadata

2411.6M37](/packages/goetas-webservices-xsd2php)[goetas-webservices/xsd2php-runtime

Convert XSD (XML Schema) definitions into PHP classes

4910.9M36](/packages/goetas-webservices-xsd2php-runtime)[egeloen/serializer

Serializer for PHP 5.6+ supporting JSON, XML, YAML &amp; CSV

28574.6k3](/packages/egeloen-serializer)[goetas/xsd2php-runtime

Convert XSD (XML Schema) definitions into PHP classes

493.3k](/packages/goetas-xsd2php-runtime)[opensoft/simple-serializer

Simple Serializer

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

Object (de)serializer component for PHP

291.7k1](/packages/tsantos-serializer)

PHPackages © 2026

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