alcalyn/serializer-doctrine-proxies
Composer 安装命令:
composer require alcalyn/serializer-doctrine-proxies
包简介
Provides Doctrine proxies handler for JMS Serializer to disable lazy-loading and recursion during serialization.
关键字:
README 文档
README
Provides Doctrine proxies handler for JMS Serializer to disable lazy-loading and recursion during serialization.
This library solves problems discussed on Stack Overflow, in this thread, or this one, and is inspired by this gist.
Installation
Using Composer:
{ "require": { "alcalyn/serializer-doctrine-proxies": "1.x" } }
Usage
You have to add a handler and a listener to your Serializer instance. Here using SerializerBuilder:
use Alcalyn\SerializerDoctrineProxies\DoctrineProxyHandler; use Alcalyn\SerializerDoctrineProxies\DoctrineProxySubscriber; use JMS\Serializer\EventDispatcher\EventDispatcher; use JMS\Serializer\Handler\HandlerRegistryInterface; use JMS\Serializer\SerializerBuilder; $serializer = SerializerBuilder::create() ->addDefaultHandlers() // This line to avoid to default handlers to be overrided by the new one. ->configureHandlers(function (HandlerRegistryInterface $handlerRegistry) { $handlerRegistry->registerSubscribingHandler(new DoctrineProxyHandler()); }) ->configureListeners(function (EventDispatcher $dispatcher) { $dispatcher->addSubscriber(new DoctrineProxySubscriber(false)); // false to disable lazy loading. }) ->build() ; $serializer->serialize($myEntityWithABunchOfRelationsIDontWantToLazyLoadDuringSerialization);
License
This project is under MIT.
统计信息
- 总下载量: 6.98k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-05-10