tsantos / serializer
Object (de)serializer component for PHP
Installs: 1 699
Dependents: 1
Suggesters: 0
Security: 0
Stars: 27
Watchers: 5
Forks: 1
Open Issues: 0
Requires
- php: ^7.1
- doctrine/instantiator: ^1.1
- jms/metadata: ^1.6
- nette/php-generator: ^3.2
- phpdocumentor/reflection-docblock: ^4.3
- pimple/pimple: ^3.2
- symfony/event-dispatcher: ^3.4 || ^4.0
- symfony/property-info: ^3.4 || ^4.0
Requires (Dev)
- doctrine/annotations: ^1.5
- friendsofphp/php-cs-fixer: ^2.12
- phpunit/phpunit: ^6.2
- symfony/yaml: ^3.4||^4.0
Suggests
- doctrine/annotations: Allow to use annotations format to define class metadata
- symfony/yaml: Allow to use Yaml format to define class metadata
This package is auto-updated.
Last update: 2024-11-28 13:52:47 UTC
README
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 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:
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
andAnnotations
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 to see all allowed configurations.
Licence
MIT
Tests
vendor/bin/phpunit -c phpunit.xml.dist