Is there a simple PHP way to minimize the class name in serialization?

Viewed 1168

I have a group of objects I need to serialize, but the class names are long, for example:

"\Namespace1\Subnamespace\dataobjectA"  
"\Namespace1\Subnamespace\dataobjectB"  
"\Namespace1\Subnamespace\dataobjectC"  
"\Namespace1\Subnamespace\dataobjectD"

using the serialize function on the objects, I get: "O:41:\"Namespace1\Subnamespace\dataobjectC\":1:{s:4:"data";s:9:"some data";}"

the serialization string contains the full class name which is sometimes bigger than the data :)

  • I'm already familiar with __sleep() ans __wakeup() functions, not useful here.

  • I understand that some king of lookup table required

My question is: Is there a simple PHP way to minimize the class name in serialization

Any suggestion are welcome

2 Answers
Related