Download the PHP package bluepsyduck/jms-serializer-factory without Composer
On this page you can find all versions of the php package bluepsyduck/jms-serializer-factory. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bluepsyduck/jms-serializer-factory
More information about bluepsyduck/jms-serializer-factory
Files in bluepsyduck/jms-serializer-factory
Package jms-serializer-factory
Short Description A Laminas factory to initialize the JMS serializer through the config.
License GPL-3.0-or-later
Homepage https://github.com/BluePsyduck/jms-serializer-factory
Informations about the package jms-serializer-factory
JMS Serializer Factory
This library provides a Laminas-compatible factory to create JMS serializer instances from the config without the need to write an actual factory.
Usage
Install the package through composer with:
composer require bluepsyduck/jms-serializer-factory
The first step is to add the settings to your Laminas config. Use the ConfigKey
interface to get the names of the
config options. A full list of options can be found below.
The JMS Serializer Factory will request any dependencies from the container, so make sure to register all of them. If
they do not have any dependencies themselves, use the InvokableFactory
to register them.
With this configuration, you now can get your serializer instance from the container:
Alternatively, if the Laminas AutoWire Factory is set up,
the Attribute UseJmsSerializer
can be used to resolve a parameter of the constructor to the configuration of the
serializer:
All config options
The following table shows the full list of config values supported by the factory. Constant
refers to the name of the
constant in the ConfigKey
interface, and the SerializerBuilder method
column refers to the method of the builder
used for that config value. For further details, please check the method signatures and doc-blocks of the builder.
Constant | Expected value | SerializerBuilder method |
---|---|---|
ACCESSOR_STRATEGY | container alias | ->setAccessorStrategy() |
EXPRESSION_EVALUATOR | container alias | ->setExpressionEvaluator() |
TYPE_PARSER | container alias | ->setTypeParser() |
ANNOTATION_READER | container alias | ->setAnnotationReader() |
DEBUG | bool | ->setDebug() |
CACHE_DIR | string | ->setCacheDir() |
ADD_DEFAULT_HANDLERS | true | ->addDefaultHandlers() |
HANDLERS | array\<container alias> | ->configureHandlers() |
ADD_DEFAULT_LISTENERS | true | ->addDefaultListeners() |
LISTENERS | array\<container alias> | ->configureListeners() |
OBJECT_CONSTRUCTOR | container alias | ->setObjectConstructor() |
PROPERTY_NAMING_STRATEGY | container alias | ->setPropertyNamingStrategy() |
SERIALIZATION_VISITORS | array\<string, container alias> | ->setSerializationVisitor() |
DESERIALIZATION_VISITORS | array\<string, container alias> | ->setDeserializationVisitor() |
ADD_DEFAULT_SERIALIZATION_VISITORS | true | ->addDefaultSerializationVisitors() |
ADD_DEFAULT_DESERIALIZATION_VISITORS | true | ->addDefaultDeserializationVisitors() |
INCLUDE_INTERFACE_METADATA | bool | ->includeInterfaceMetadata() |
METADATA_DIRS | array\<string, string> | ->setMetadataDirs() |
METADATA_DRIVER_FACTORY | container alias | ->setMetadataDriverFactory() |
SERIALIZATION_CONTEXT_FACTORY | container alias | ->setSerializationContextFactory() |
DESERIALIZATION_CONTEXT_FACTORY | container alias | ->setDeserializationContextFactory() |
METADATA_CACHE | container alias | ->setMetadataCache() |
DOC_BLOCK_TYPE_RESOLVER | bool | ->setDocBlockTypeResolver() |
Notes:
- The expected value
container alias
means that a string is expected, which is used in the container to retrieve an actual instance to set to the serializer builder. The actually needed type of the instance can be checked in the related method of the SerializerBuilder. - The serialization and deserialization visitors get added to the builder together with their format string. The config is expecting the format as key, and an alias to the visitor factory as value.
METADATA_DIRS
expects the array key to be the namespace and the value to be the directory with the meta config files.- The factory does only support classes implementing the
SubscribingHandlerInterface
as handlers, and classes implementing theEventSubscriberInterface
as listeners. It is not possible to use callables for these two cases.
All versions of jms-serializer-factory with dependencies
bluepsyduck/laminas-autowire-factory Version ^2.0
jms/serializer Version ^3.0