Download the PHP package paysera/lib-normalization without Composer
On this page you can find all versions of the php package paysera/lib-normalization. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download paysera/lib-normalization
More information about paysera/lib-normalization
Files in paysera/lib-normalization
Package lib-normalization
Short Description Library for normalizing and denormalizing PHP objects to and from JSON structures
License MIT
Informations about the package lib-normalization
Normalization library
This library allows to de/normalize your business entities (plain PHP objects) without tightly coupling them with your normalization format. You would usually do this before converting normalized structure to JSON or after converting from it.
If you intend to use the library with Symfony, use lib-normalization-bundle instead.
Why?
Symfony has Serializer component that has normalizers as a part of it. This component is created for similar reasons but with different approach.
Symfony component exposes your business entities by default, but allows sophisticated but challenging configuration options. It also writing custom normalization logic, but it usually resides inside your normalized classes (which probably are plain PHP objects).
Paysera Normalization library embraces simplicity by always writing a bit of code for getting full control of the situation – normalization logic is placed in related classes, which are usually registered from DIC. This allows to use other services, fetch data from database, call remote services if needed or make any other things in familiar PHP source code. You can easily rename any fields, use any custom naming, duplicate some data for backward compatibility or, well, just write any other code. No difficult configuration is needed for edge-cases, as you have full control over the situation.
Main features of this library:
- supports explicit type safety when denormalizing by integrating lib-object-wrapper;
- normalization type can be guessed by passed data;
- easily reuse other de/normalizers without direct dependencies;
- supports different normalization groups with fallback to default one;
- supports explicitly or implicitly included fields, allowing performance tuning in normalization process.
Installation
Usage
Basic usage
Write de/normalizers for your business entities:
Register all de/normalizers in the provider:
Create needed services:
Use for de/normalization:
For advanced usage please also see lib-normalization-bundle and the source code.
If you have any questions, feel free to create an issue.
Semantic versioning
This library follows semantic versioning.
See Symfony BC rules for basic information about what can be changed and what not in the API.
Running tests
Contributing
Feel free to create issues and give pull requests.
You can fix any code style issues using this command: