PHPackages                             stopsopa/jms-serializer-lite - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. stopsopa/jms-serializer-lite

ActiveLibrary[API Development](/categories/api)

stopsopa/jms-serializer-lite
============================

Simple library to easy dump/serialize objects/arrays from db to make it ready to expose through RESTful API - one direction

v1.3.0(9y ago)01.1k[1 issues](https://github.com/stopsopa/jms-serializer-lite/issues)MITPHPPHP ^5.3 || ^7.0

Since Oct 6Pushed 2y ago1 watchersCompare

[ Source](https://github.com/stopsopa/jms-serializer-lite)[ Packagist](https://packagist.org/packages/stopsopa/jms-serializer-lite)[ RSS](/packages/stopsopa-jms-serializer-lite/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (6)Used By (0)

[![Build Status](https://camo.githubusercontent.com/ba5997f1abbd4bf6a59f084b956c3561726dd671bc6c14b65cdab760976bb59f/68747470733a2f2f7472617669732d63692e6f72672f73746f70736f70612f6a6d732d73657269616c697a65722d6c6974652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/stopsopa/jms-serializer-lite)[![Coverage Status](https://camo.githubusercontent.com/845606df2948631294950cf80b375661c691eb495039f1b9e051c0c4b3fce52b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f73746f70736f70612f6a6d732d73657269616c697a65722d6c6974652f62616467652e737667)](https://coveralls.io/github/stopsopa/jms-serializer-lite)[![Latest Stable Version](https://camo.githubusercontent.com/d876cbf5525a85ccae9f58a814aa9653fd52900f52aea9e53b7e0518b96d04cf/68747470733a2f2f706f7365722e707567782e6f72672f73746f70736f70612f6a6d732d73657269616c697a65722d6c6974652f762f737461626c65)](https://packagist.org/packages/stopsopa/jms-serializer-lite)

DEPRECATED
==========

[](#deprecated)

Created in 2016 - quite old now and not maintained.

That was actually usefull a lot back then. But please don't use it now.

Why?
====

[](#why)

Usually first choice of library for Symfony 2/3 to dump data from db to provide any RESTful feeds is [jms/serializer](http://jmsyst.com/libs/serializer). This tool is designed to serialize and unserialize data to xml, json, or yml and back to initial data structures. But usually there is need to just provide data into one direction - to json feeds. Additionally usually there is need to serialize the same object in different ways. In jms/serializer and similar complex tools usually you can use "groups", unfortunately this solution is not flexible enough to deal with real life situations.

So what does this library special do?

This library gives you ability to serialize any nested data structures (usually ORM objects) to any array structure, ready to json\_encode in simplest possible way, without loosing flexibility and without loosing inheritance to provide new serialization format by changing (overriding) old format. This library is also framework agnostic.

Readme
======

[](#readme)

- [Basic usage](#documentation)
- [Nested entities](#nested-entities)
- [Serialize from different angles](#serialize-from-different-angles)
- [Shorter syntax and helper](#shorter-syntax-and-helper)
    - [Default values](#default-values)
    - [Excluding/Omitting entities](#excludingomitting-entities)
    - [Save keys](#save-keys)
    - [DumperInterface](#dumperinterface)
    - [Force mode](#force-mode)
    - [Scope and stack](#scope-and-stack)

Installation
============

[](#installation)

```
composer require stopsopa/jms-serializer-lite

```

Documentation
=============

[](#documentation)

When You have ORM entities like ...

```
Article:
    id
    title
    content
    comments #

Comment
    id
    article #
    user #
    content

User
    id
    login
    name
    surname
    comments #

```

... and there is need to serialize **Article** to RESTful feed:

```
{
    "id": 1,
    "name": "First article",
    "body": "Content of first article"
}
```

The simplest way to start do that using this library is to create simple class (e.g.) **NewDumper** that extends class **Stopsopa\\LiteSerializer\\Dumper** ...

```
