Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Jms Serializer Bidirectional Relation Laravel Package

coosos/jms-serializer-bidirectional-relation

Adds JMS Serializer subscribers that embed a _mapping_bidirectional_relation in serialized data so bidirectional associations can be restored on deserialize. Supports Symfony or standalone setup via event subscribers, with annotations to enable mapping on root models and exclude fields.

View on GitHub
Deep Wiki
Context7

JMS Serializer Bidirectional Relation

Description

Build a mapping for restore bidirectional relation when deserialize process.

This mapping is add to your serialized content with _mapping_bidirectional_relation key.

Install

With jms/serializer (without symfony)

use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\EventDispatcher\EventDispatcher;
use Coosos\BidirectionalRelation\EventSubscriber\MapDeserializerSubscriber;
use Coosos\BidirectionalRelation\EventSubscriber\MapSerializerSubscriber;

$builder = SerializerBuilder::create();
$builder->configureListeners(function (EventDispatcher $dispatcher) {
    $dispatcher->addSubscriber(new MapSerializerSubscriber());
    $dispatcher->addSubscriber(new MapDeserializerSubscriber());
});

$serializer = $builder->build();

With Symfony

# services.yml
Coosos\BidirectionalRelation\EventSubscriber\MapDeserializerSubscriber:
      tags:
        - { name: jms_serializer.event_subscriber }

Coosos\BidirectionalRelation\EventSubscriber\MapSerializerSubscriber:
      tags:
        - { name: jms_serializer.event_subscriber }

Usage

Annotation (Minimum required)

For to avoid mapping on an object that does not need it, you should add @Coosos\BidirectionalRelation\Annotations\SerializerBidirectionalRelation to annotation class (only root model)

Exclude from mapping

If you want to exclude an object to map, you can by adding @Coosos\BidirectionalRelation\Annotations\ExcludeFromMapping annotation to your field.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity