Download the PHP package opensoft/simple-serializer without Composer
On this page you can find all versions of the php package opensoft/simple-serializer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download opensoft/simple-serializer
More information about opensoft/simple-serializer
Files in opensoft/simple-serializer
Package simple-serializer
Short Description Simple Serializer
License MIT
Homepage http://github.com/opensoft/simple-serializer
Informations about the package simple-serializer
Simple-Serializer
Introduction
Simple-Serializer allows you to serialize your objects into a requested output format such as JSON. The library is written to work with DTO objects in the REST services.
Built-in features include:
- (de-)serialize object graphs
- supports boolean, integer, double, DateTime\<format>, array, T, array\<T>, null types, where "T" - is some PHP object.
- configurable via YAML
- three unserialize mode (non-strict, medium strict, strict)
Unserialize mode: Non-Strict mode - serializer does not check incoming parameters Medium Strict - serializer extra check incoming parameters and if they exist throw InvalidArgumentException Strict - serializer extra check incoming parameters completely as expected if there are extra arguments or missing some, it throws an exception.
Some Restrictions:
- object must have configuration for serialize/unserialize
Possible TODO list:
- (de-)serialize object graphs of any complexity including circular references
- configurable via PHP, XML, or annotations
- custom integrates with Doctrine ORM, et. al.
It should be noted that Simple-Serializer is realy simple library with minimum configuration, but it provides wide opportunity for create REST API.
Installation
To install Simple-Serializer with Composer just add the following to your composer.json
file:
Then, you can install the new dependencies by running Composer's update
command from the directory where your composer.json
file is located:
$ php composer.phar update
Configuration
- expose
- true
- false (default)
- type
- integer
- boolean
- double
- string
- array
- T - fully qualified class name
- array\<T>
- DateTime
- DateTime\<format>
- format could be name of DateTime constant (COOKIE, ISO8601), string or empty (default format is ISO8601)
- serialized_name
- default value is equal name property
- since_version
- string
- until_version
- string
- groups
- array
- null_skipped
- true
- false (default)
Serializing Objects
Most common usage is probably to serialize objects. This can be achieved very easily:
Deserializing Objects
You can also unserialize objects from JSON representation. For example, when accepting data via an API.