Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tsantos84/fast-object-normalizer

Increase serialization performance of Symfony Serializer component
https://github.com/tsantos84/fast-object-normalizer

Last synced: about 11 hours ago
JSON representation

Increase serialization performance of Symfony Serializer component

Awesome Lists containing this project

README

        

# [WIP] Symfony Fast Object Normalizer
[![Build status][main image]][main] [![Coverage Status][main coverage image]][main coverage]

Symfony Object Normalizer that improves the serialization process [up to 5x (e.g. 400%)][benchmark] compared to built-in normalizers.
This boost of performance can be accomplished because this normalizer generates dedicated normalizes to your
data classes, so you don't need to worry about runtime overhead like reflections or code relying on metadata
(e.g. ClassMetadata).

## Instalation

composer require tsantos/fast-object-normalizer

### Symfony Applications

This package ships with a Symfony Bundle that autmatically adds the normalizer to the normalizer stack.

#### Applications using Flex

Just install the package and the Symfony Flex automatically register the bundle into your application.

#### Applications not using Flex

You need to register the bundle manually:

```php
['all' => true]
];
```

### Standalone Applications

For applications using Symfony Serializer as a standalone component, you'll need to register the normalizer
manually:

```php
new JsonEncoder()]);
```

Note that `ObjectNormalizer` still in the normalizer stack. This is not a requirement, but it is a good idea to have
the built-in normalizer working because `Fast Object Normalizer` may not support the object that is being serialized.

## Configuration

`Fast Object Normalizer` is aimed to serialize data class (e.g: DTO), but in somecases it is possible that your
application tries to serialize an object which holds a resource or a connection and normally there is an exclusive
normalizer that deals with that type. To ensure that `Fast Object Normalizer` skip such types, you can configure it
to serialize only types that matchs some pattern:

```php