Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/tsantos84/fast-object-normalizer
- Owner: tsantos84
- License: mit
- Created: 2022-08-27T19:06:09.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-01T15:56:16.000Z (over 2 years ago)
- Last Synced: 2024-12-18T00:51:55.956Z (6 days ago)
- Language: PHP
- Size: 152 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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