Re: Improve PHP 7 serialization
| From: | Kalle Sommer Nielsen | Date: | Wed, 24 Sep 2014 02:20:21 +0000 |
| Subject: | Re: Improve PHP 7 serialization | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-77564@lists.php.net to get a copy of this message | ||
Hi
2014-09-23 23:56 GMT+02:00 Park Framework <park.framework@gmail.com>:
> In php.ini add the directive
> serialization.method = msgpack / Igbinary / ....
There is an even better way to do this; add an additional parameter to
serialize and unserialize to serialize as and unserialize as:
$bin = serialize($data_struct, 'igbinary');
$data_struct = unserialize($bin, 'igbinary');
This keeps a clean BC solution without adding more clutter to the ini
file for runtime things, you could say that adding something like
'serialize_default_mode = php;', but changing its default would create
clutter code where the optional second parameter would be forced, so
lets leave the ini out of this.
So what I propose here is:
1) An internal API to register serializes,and making PHP's current
serialize implemented as such
2) Add a second parameter to both serialize and unserialize that can
be used choose a serializer
3) Optionally add a function like: get_serialize_handlers() (so we
won't have to parse phpinfo()) which are the available serializers
4) Consider bundling either igbinary, msgpack or implement a new
custom and more efficient one that allows us to be future oriented
5) No php.ini changes
6) Allow users to register serialize handlers using
register_serialize_handler()/unregister_serialize_handler()
7) Optionally consider implementing this in SPL
Okay, late night, back to sleep!
--
regards,
Kalle Sommer Nielsen
kalle@php.net