Download the PHP package vuryss/serializer without Composer
On this page you can find all versions of the php package vuryss/serializer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vuryss/serializer
More information about vuryss/serializer
Files in vuryss/serializer
Package serializer
Short Description A fast, extensible PHP data structures serializer & deserializer
License MIT
Informations about the package serializer
Fast serialization library
Serializes and deserializes complex data structures to and from json. Ideas taken from Symfony's Serializer component, Serde and others.
Symfony serializer was very flexible, but also very slow. This library tries to be as fast as possible.
Supports modern PHP projects with fully typed properties. Older codebases with no types would not work.
- Fast serialization library
- Installation
- Features
- Serialization
- Deserialization
- Caching - optional, but highly recommended, otherwise the library will be slow
- Custom object property serialized name
- Serialization groups
- Deserialization groups
- Custom date format
- Enforce date format
- Ignore property
- Handling of NULL values
- Support for json serializable objects
- Support for Symfony Serializer attributes
- Build, run & test locally
Installation
Features
Serialization
- Properties are serialized if they are either public or have a getter method.
Deserialization
- Properties are deserialized if they are public, instantiable in public constructor or have a setter method.
Caching - optional, but highly recommended, otherwise the library will be slow
Supports PSR-6 CacheItemPoolInterface: https://www.php-fig.org/psr/psr-6/#cacheitempoolinterface
No need to chain in-memory cache with external cache, the library will do it for you. Cache will be called once per used class (used in serialization or deserialization), then will be cached in memory until the script ends.
Custom object property serialized name
Serialization groups
Deserialization groups
Custom date format
On serialization the format will always be respected. On deserialization the format will be used to parse the date. However on deserialization by default if the date is not in the provided format, it will be parsed as is, given that DateTime constructor can parse it.
Per property:
Or globally:
Enforce date format
If strict data time format is required during deserialization then, you can use the
SerializerInterface::ATTRIBUTE_DATETIME_FORMAT_STRICT
attribute:
Per property:
Or globally:
Ignore property
Those properties will not be included in the serialized values during serialization and will not be populated with provided values during deserialization.
Handling of NULL values
- By default, NULL values are included in the serialized value.
To disable this you can use the SerializerInterface::ATTRIBUTE_SKIP_NULL_VALUES
attribute:
Per property:
Or globally:
Support for json serializable objects
If an object implements the JsonSerializable
interface, the jsonSerialize
method will be called and the result will be serialized.
Support for Symfony Serializer attributes
This library aims to be a drop-in replacement for Symfony Serializer. It supports the following attributes:
- Groups
- SerializedName
- Ignore
Build, run & test locally
To enter the prepared container environment:
Install package dependencies:
Run tests:
HTML Coverage locally:
All versions of serializer with dependencies
symfony/property-info Version ^7.0
phpdocumentor/reflection-docblock Version ^5.4.1
phpstan/phpdoc-parser Version ^2.0
psr/cache Version ^3.0