定制 alcalyn/serializer-doctrine-proxies 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Latest Stable Version Total Downloads License

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

GitHub 信息

  • Stars: 9
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固