ivory / serializer
Serializer for PHP 7.0+ supporting JSON, XML, YAML & CSV
Installs: 167 826
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 22
Open Issues: 2
Requires
- php: >=7.0
- doctrine/instantiator: ^1.0
- doctrine/lexer: ^1.0
- symfony/options-resolver: ^4.3 || ^5.0
Requires (Dev)
- ext-dom: *
- ext-json: *
- ext-simplexml: *
- doctrine/annotations: ^1.2 || ^1.3
- friendsofphp/php-cs-fixer: ^2.0
- mockery/mockery: ^1.3 || ^1.4
- phpdocumentor/reflection: ^3.0 || ^4.0
- phpunit/phpunit: ^6.5 || ^7.5 || ^8.5 || ^9.5
- psr/cache: ^1.0
- symfony/event-dispatcher: ^3.0 || ^4.3 || ^5.2
- symfony/phpunit-bridge: ^3.0 || ^4.3 || ^5.2
- symfony/property-access: ^3.0 || ^4.3 || ^5.2
- symfony/property-info: ^3.0 || ^4.3 || ^5.2
- symfony/yaml: ^3.0 || ^4.3 || ^5.0
Suggests
- ext-dom: Allow you to use the XML serialization visitor and mapping.
- ext-json: Allow you to use the JSON serialization/deserialization visitors and mapping.
- ext-simplexml: Allow you to use the XML deserialization visitor and mapping.
- doctrine/annotations: Allow you to use the mapping annotations.
- phpdocumentor/reflection: Allow you to parse PHP type more efficiently
- symfony/event-dispatcher: Allow you to use the event dispatching system.
- symfony/property-access: Allow you to use the Symfony accessor/mutator.
- symfony/property-info: Allow you to use the mapping type auto discovery.
- symfony/yaml: Allow you to use the YAML serialization/deserialization visitors and mapping.
Replaces
- egeloen/serializer: ^1.0.0
This package is auto-updated.
Last update: 2024-03-01 18:27:56 UTC
README
Overview
The Ivory Serializer is a PHP ^7.0 library allowing you to (de)-serialize complex data using the visitor pattern recursively on each node of the graph. It supports the CSV, JSON, XML and YAML formats. It also supports features such as exclusion strategies (groups, max depth, circular reference, version, ...), naming strategies (camel case, snake case, studly caps), automatic/explicit mapping (reflection, annotation, XML, YAML, JSON) and many others...
use Ivory\Serializer\Format; use Ivory\Serializer\Serializer; $stdClass = new \stdClass(); $stdClass->foo = true; $stdClass->bar = ['foo', [123, 432.1]]; $serializer = new Serializer(); echo $serializer->serialize($stdClass, Format::JSON); // {"foo": true,"bar": ["foo", [123, 432.1]]} $deserialize = $serializer->deserialize($json, \stdClass::class, Format::JSON); // $deserialize == $stdClass
Documentation
Testing
The library is fully unit tested by PHPUnit with a code coverage close to 100%. To execute the test suite, check the travis configuration.
Contribute
We love contributors! Ivory is an open source project. If you'd like to contribute, feel free to propose a PR! You can follow the CONTRIBUTING file which will explain you how to set up the project.
License
The Ivory Serializer is under the MIT license. For the full copyright and license information, please read the LICENSE file that was distributed with this source code.