kunicmarko/jms-messenger-adapter

Use JMS Serializer with Symfony Messenger.

0.2.3 2019-11-02 11:14 UTC

This package is auto-updated.

Last update: 2019-12-02 11:35:34 UTC


README

Use JMS Serializer with Symfony Messenger.

PHP Version Latest Stable Version Latest Unstable Version

Build Status Coverage Status

Documentation

Installation

Add dependency with Composer:

composer require kunicmarko/jms-messenger-adapter

Symfony

Enable the bundle for all environments:

// bundles.php
return [
    //...
    KunicMarko\JMSMessengerAdapter\Bridge\Symfony\JMSMessengerAdapterBundle::class => ['all' => true],
];

Configuration

#config/packages/jms_messenger.yaml
jms_messenger:
    format: json # xml, json
    serializer_id: messenger.transport.jms_serializer

Serialized id should be configured in the messenger config, in case you did not get the recipe, just add:

#config/packages/jms_messenger.yaml
framework:
  messenger:
    enabled: true
    serializer:
      default_serializer: messenger.transport.jms_serializer

Stamps

This library provides additional stamps that will use JMS Deserialization/Serialization Context for serializing/deserializing messages.

use JMS\Serializer\SerializationContext;
use KunicMarko\JMSMessengerAdapter\Stamp\SerializationContextStamp;

$context = SerializationContext::create();
$context->setGroups(['foo']);
        
$messageBus->dispatch(new Message(), [new SerializationContextStamp($context)]);