======== Overview ======== This bundle allows you to easily serialize/unserialize objects. Main features include: - able to handle circular references, and object graphs of any depth without writing a single line of code - serialize/unserialize objects using annotations to describe metadata - supports versioning out of the box - easily customizable as most logic is implemented using clearly defined interfaces You need to have control over the objects that you want to serialize/unserialize. This bundle does not work for objects provided by a third-party. TODO: - the unserialization process is not yet completely implemented (I currently don't need it, but contributions are welcome) Installation ------------ Checkout a copy of the code:: git submodule add https://github.com/schmittjoh/SerializerBundle.git src/JMS/SerializerBundle Then register the bundle with your kernel:: // in AppKernel::registerBundles() $bundles = array( // ... new JMS\SerializerBundle\JMSSerializerBundle(), // ... ); Configuration ------------- Below is the default configuration, you don't need to change it unless it doesn't suit your needs:: jms_serializer: naming_strategy: separator: _ lower_case: true encoders: xml: true json: true Usage ----- Factory vs. Default Instance ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The bundle configures a factory, and a default serializer for you that you can use in your application code. The default serializer is used if you do not care about versioning:: $serializer = $container->get('serializer'); The serializer factory can be used if you want to display a specific version of an object:: $factory = $container->get('serializer_factory'); $serializer = $factory->getSerializer('1.0.0'); Versioning ~~~~~~~~~~ The bundle allows you to have different versions of your objects. This can be achieved by using the @Since, and @Until annotation which both accept a standardized PHP version number. :: camel_case. @Since ~~~~~~ This annotation can be defined on a property to specify starting from which version this property is available. If an earlier version is serialized, then this property is excluded automatically. The version must be in a format that is understood by PHP's ``version_compare`` function. @Until ~~~~~~ This annotation can be defined on a property to specify until which version this property was available. If a later version is serialized, then this property is excluded automatically. The version must be in a format that is understood by PHP's ``version_compare`` function.