brettminnie/breakfast-serializer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

brettminnie/breakfast-serializer

最新稳定版本:0.1.0

Composer 安装命令:

composer require brettminnie/breakfast-serializer

包简介

Library for (de-)serializing data of any complexity to JSON

README 文档

README

Build Status Scrutinizer Code Quality Dependency Status Coverage Status

A replacement for the other well known serializer, initially we were aiming for backwards compatibility, however it seemed more appropriate to develop a lightweight alternative. We are forgoing the depth of features now to offer something that is easy to configure and works well without any configuration.

Installation

$ composer require brettminnie/breakfast-serializer:0.1.*

Job done, start enjoying your morning serial!

Configuration

Out the box will do a full depth/breadth recursion and serialize to JSON format, no config is required. It will always serialize with a variable called className attached to the object. This is a fully fledged namespace and is required to deserialize. If you want to deserialize from JSON data that is missing this variable it needs to be injected into the object.

Supported Serialization Formats

  • JSON
  • XML
  • PHP Object Notation
  • YAML

Features

  • Simple limiting of traversal depth
  • Mapping of properties to alternate names and back again
  • Excluding of properties from serialization and ignoring them on deserialization
  • Simple YAML config format (Yay no slow php annotations!)

Quick and Dirty Example

   
    // To retrieve the json representation json of an object
    $jsonData = BDBStudios\BreakfastSerializer\SerializerFactory::getSerializer()
        ->serialize($myClass);
   
   // To unserialize
   $myClass = BDBStudios\BreakfastSerializer\SerializerFactory::getSerializer()
        ->deserialize($jsonData);
   
   //To serialize an object with a limited depth recursion (aka only some of it)
   $jsonData = 
      BDBStudios\BreakfastSerializer\SerializerFactory::getSerializer(
         BDBStudios\BreakfastSerializer\IsSerializable::FORMAT_JSON,
         2
      )
      ->serialize($myClass);
    

Further examples in the documentation directory.

统计信息

  • 总下载量: 26
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-27