PHPackages                             fdevs/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. fdevs/serializer

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

fdevs/serializer
================

FDevs Serializer Component

0.1.1(9y ago)14.2k1[1 PRs](https://github.com/4devs/serializer/pulls)2MITPHPPHP &gt;=5.5.9

Since Jun 20Pushed 4y ago4 watchersCompare

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

READMEChangelogDependencies (4)Versions (5)Used By (2)

Serializer
==========

[](#serializer)

[![Build Status](https://camo.githubusercontent.com/ff035d9fc6ef7f388754d2a2fa8b59c59c61cf4c39b08e6c857b9d554a51d44c/68747470733a2f2f7472617669732d63692e6f72672f34646576732f73657269616c697a65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/4devs/serializer)

If you use Symfony 2, you could use our [serializer bridge](https://github.com/4devs/serializer-bridge)!

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

[](#installation)

Serializer uses Composer, please checkout the [composer website](http://getcomposer.org) for more information.

The simple following command will install `serializer` into your project. It also add a new entry in your `composer.json` and update the `composer.lock` as well.

```
composer require fdevs/serializer
```

Usage examples
--------------

[](#usage-examples)

\###create model

```

        true

            id

                short

                App\Model\User

                object

                    App\Model\Comment

```

### init Serializer

[](#init-serializer)

```
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Encoder\XmlEncoder;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use FDevs\Serializer\Normalizer\ObjectNormalizer as FDevsNormalizer;
use FDevs\Serializer\Mapping\Factory\LazyLoadingMetadataFactory;
use FDevs\Serializer\Mapping\Loader\XmlFilesLoader;
use App\Model\Post;

$files = ['/path/to/xml/Model.Post.xml'];
$loader = new XmlFilesLoader($files);

//init metadata factory
$loadingMetadata = new LazyLoadingMetadataFactory($loader);

$encoders = array(new XmlEncoder(), new JsonEncoder());
$normalizers = array(new FDevsNormalizer($loadingMetadata), new ObjectNormalizer());

$serializer = new Serializer($normalizers, $encoders);

//init $post
$post = new Post();
echo $serializer->serialize($post);

//get your array data
$data = [];
$post = $serializer->serialize($data,Post::class);
```

Options
-------

[](#options)

options are of two types NameConverting and Visible options can be used at the level of properties and class

NameConverting are used to change the name:

- camel\_to\_snake
- name-prefix
- serialized-name

Visible is used to display the value:

- fields
- group

```

        true

            id

                short

            pre_

```

### add Option

[](#add-option)

#### create your NameConverting option

[](#create-your-nameconverting-option)

```

        _suffix

            1.0

```

#### add option to the Normalizer

[](#add-option-to-the-normalizer)

```
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Encoder\XmlEncoder;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use FDevs\Serializer\Normalizer\ObjectNormalizer as FDevsNormalizer;
use FDevs\Serializer\Mapping\Factory\LazyLoadingMetadataFactory;
use FDevs\Serializer\Mapping\Loader\XmlFilesLoader;
use FDevs\Serializer\OptionRegistry;
use App\Serializer\Option\NameConverter\NameSuffix;
use App\Serializer\Option\Visible\VersionOption;
use FDevs\Serializer\DataTypeFactory;
use App\Model\Post;

$files = ['/path/to/xml/Model.Post.xml'];
$loader = new XmlFilesLoader($files);

//init metadata factory
$loadingMetadata = new LazyLoadingMetadataFactory($loader);

//create OptionRegistry
$optionRegistry = new OptionRegistry();
$optionRegistry->addOption(new NameSuffix());
$optionRegistry->addOption(new VersionOption());

//create DataTypeFactory
$dataTypeFactory = new DataTypeFactory();

$normalizer = new FDevsNormalizer($loadingMetadata, $dataTypeFactory, $optionRegistry);

$serializer = new Serializer([$normalizer, new ObjectNormalizer()], [new XmlEncoder(), new JsonEncoder()]);
```

License
-------

[](#license)

This library is under the MIT license. See the complete license in the library:

```
LICENSE

```

---

Created by [4devs](http://4devs.pro/) - Check out our [blog](http://4devs.io/) for more insight into this and other open-source projects we release.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~315 days

Total

3

Last Release

2988d ago

Major Versions

0.1.1 → 1.0.x-dev2018-03-13

PHP version history (2 changes)0.1.0PHP &gt;=5.5.9

1.0.x-devPHP &gt;=5.5.9 || ^7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1908507?v=4)[andrey](/maintainers/andrey1s)[@andrey1s](https://github.com/andrey1s)

---

Top Contributors

[![vmelnik-ukraine](https://avatars.githubusercontent.com/u/1994051?v=4)](https://github.com/vmelnik-ukraine "vmelnik-ukraine (2 commits)")[![fink3l](https://avatars.githubusercontent.com/u/2669980?v=4)](https://github.com/fink3l "fink3l (1 commits)")[![realkasparov](https://avatars.githubusercontent.com/u/16748817?v=4)](https://github.com/realkasparov "realkasparov (1 commits)")

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[symfony/serializer-pack

A pack for the Symfony serializer

1.1k28.2M221](/packages/symfony-serializer-pack)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.3M26](/packages/league-geotools)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)

PHPackages © 2026

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