https://github.com/tsantos84/serializer
A PHP serialization component focused on performance
https://github.com/tsantos84/serializer
data-transformation php-library php7 serialization-library
Last synced: 3 months ago
JSON representation
A PHP serialization component focused on performance
- Host: GitHub
- URL: https://github.com/tsantos84/serializer
- Owner: tsantos84
- License: mit
- Created: 2017-06-21T21:30:14.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-05-28T03:51:56.000Z (about 6 years ago)
- Last Synced: 2025-12-02T14:57:48.016Z (6 months ago)
- Topics: data-transformation, php-library, php7, serialization-library
- Language: PHP
- Homepage: https://tsantos-serializer.readthedocs.io/
- Size: 561 KB
- Stars: 28
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# TSantos Serializer
[](https://travis-ci.org/tsantos84/serializer) [](https://sonarcloud.io/dashboard?id=tsantos84_serializer) [](https://sonarcloud.io/dashboard?id=tsantos84_serializer) [](https://packagist.org/packages/tsantos/serializer) [](https://packagist.org/packages/tsantos/serializer) [](//packagist.org/packages/tsantos/serializer) [](https://packagist.org/packages/tsantos/serializer) [](https://packagist.org/packages/tsantos/serializer)
TSantos Serializer is a library to encode/decode PHP objects to some string representation. Because of its exclusive
serialization strategy, this library is the [faster serialization component](https://github.com/tsantos84/serializer-benchmark) to PHP.
## Instalation
You can install this library through composer:
`composer require tsantos/serializer`
or just add `tsantos/serializer` to your composer file and then
`composer update`
## Usage
The best way to get start with `TSantos Serializer` is by using the builder.
With a few configurations you are ready to serialize your data:
```php
use TSantos\Serializer\SerializerBuilder;
class Post {
public $title;
public $summary;
}
$serializer = (new SerializerBuilder())
->setHydratorDir('/path/to/generated/hydrators')
->build();
$person = new Post('Post title', 'Post summary');
echo $serializer->serialize($person); // {"title":"Post title", "summary":"Post summary"}
```
This is the simplest example to get you started with TSantos Serializer. There are
a lot of capabilities which you should know in order to master your serializer instance
and take advantage of all library's power.
## Features
Main features currently supported by TSantos Serializer:
* No need to mapping classes for simple use cases ...
* ... but supports `YAML`, `XML` and `Annotations` mapping formats for advanced mapping
* Supports `JSON` encoders
* (De-)serializes objects of any depth
* Virtual properties
* Properties grouping
* Event listeners to hook into serialization operations
* (De-)serializes interfaces and abstract classes
## Documentation
Please refer to the [documentation page](https://tsantos-serializer.readthedocs.io) to see all allowed configurations.
## Licence
MIT
## Tests
`vendor/bin/phpunit -c phpunit.xml.dist`