Download the PHP package blackprism/serializer without Composer
On this page you can find all versions of the php package blackprism/serializer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download blackprism/serializer
More information about blackprism/serializer
Files in blackprism/serializer
Package serializer
Short Description Fast and simple json serializer library
License Apache-2.0
Informations about the package serializer
Not maintained anymore, Symfony Serializer is enough.
Serializer
A fast and simple json serializer library for PHP 7.0+
Serializer has been designed to be very fast and with low memory usage.
How to use it ?
According you have these objects you want to serialize/unserialize
First you need to setup the configuration, pure PHP, no yml, no xml. Faster and lighter.
Now, you can serialize an object
Output is:
And unserialize a json
Output is:
Custom handler
From previous sample, you change a bit the configuration to this:
You have a collection of object at root node?
Assuming you have this json:
You need to use deserializeCollection:
You can use it to serialize/unserialize for a noSQL
When using a nosql you often add a property to your document to specify what type of document it is, for example:
Configuration for identified document
Now, you can serialize to a typed object json
Output is:
And unserialize a typed object json
Output is:
Note: You have identified document, so you don't need to use deserializeCollection even if the root node is a collection.
Benchmark
For 100,000 iterations :
Library | Serialize time | Serialize memory | Deserialize time | Deserialize Memory |
---|---|---|---|---|
JMS Serializer | 1.951 sec | 1537 KB | 1.829 sec | 1547 KB |
Symfony Serializer | 0.210 sec | 486 KB | 0.298 sec | 488 KB |
Blackprism Serializer | 0.352 sec | 464 KB | 0.311 sec | 457 KB |
Test protocol can be found on Serializer Benchmark
Conclusion
As you can see, Blackprism Serializer isn't really the fastest, but it has a quick and simple configuration with very good performance, almost the same as Symfony Serializer which has a more complex configuration.