PHPackages                             koesie10/lua-serializer - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. koesie10/lua-serializer

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

koesie10/lua-serializer
=======================

A Lua serializer/deserializer

v0.4(8y ago)62.0k2[1 PRs](https://github.com/koesie10/LuaSerializer/pulls)MITPHPPHP &gt;=5.4

Since Dec 21Pushed 6y ago1 watchersCompare

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

READMEChangelog (4)Dependencies (5)Versions (5)Used By (0)

PHP Lua Serializer/Deserializer
===============================

[](#php-lua-serializerdeserializer)

[![Build](https://camo.githubusercontent.com/b8921efc0fcc75fb2b14364c8ceadafa41c3153b19f23d331d1855df95c45467/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f6275696c642f672f6b6f6573696531302f4c756153657269616c697a65722e737667)](https://scrutinizer-ci.com/g/koesie10/LuaSerializer)[![Version](https://camo.githubusercontent.com/9510972f01eeff617745f8dca59cac0d75111d2bc9e8df49e86f8813f8dad71e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6f6573696531302f6c75612d73657269616c697a65722e737667)](https://packagist.org/packages/koesie10/lua-serializer)[![License](https://camo.githubusercontent.com/109a76cba59cb32b8b49bfd994b7a58ac124327cb7995ca84eccfad9298d99bc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6b6f6573696531302f6c75612d73657269616c697a65722e737667)](https://packagist.org/packages/koesie10/lua-serializer)[![Code Coverage](https://camo.githubusercontent.com/5b2ecbecc0e1ee98999c698d8ad84eefe60afd6dc3f16d149ea6184cfa4da8b8/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6b6f6573696531302f4c756153657269616c697a65722e737667)](https://scrutinizer-ci.com/g/koesie10/LuaSerializer)[![Code Quality](https://camo.githubusercontent.com/bdd4fd39886f613f4a898e5c165cd967328364909980d0f6deea1750ace2804b/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6b6f6573696531302f4c756153657269616c697a65722e737667)](https://scrutinizer-ci.com/g/koesie10/LuaSerializer)[![Downloads](https://camo.githubusercontent.com/98202635da0f19b41c67955d80e4e7d70e3bf47bf79c1ba1b4e7ac4caa030dbb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b6f6573696531302f6c75612d73657269616c697a65722e737667)](https://packagist.org/packages/koesie10/lua-serializer)

This is a very simple Lua serializer/deserializer for PHP, with support for [JMS Serializer](https://github.com/schmittjoh/serializer).

Installation
------------

[](#installation)

Install with [Composer](http://getcomposer.org):

```
composer require koesie10/lua-serializer

```

Usage
-----

[](#usage)

There is a facade for both serialization and deserialization:

```
$result = \Vlaswinkel\Lua\Lua::serialize([ 'foo' => 'bar']);
/**
 * Returns:
 * {
 *      foo = "bar",
 * }
 */

$result = \Vlaswinkel\Lua\Lua::deserialize('{ foo = "bar" }')
/**
 * Returns:
 * [ 'foo' => 'bar' ]
 */
```

You can also use all the classes yourself:

```
$result = \Vlaswinkel\Lua\Serializer::encode([ 'foo' => 'bar' ]); // returns the same as above

$parser = new \Vlaswinkel\Lua\Parser(new \Vlaswinkel\Lua\TokenStream(new \Vlaswinkel\Lua\InputStream('{ foo = "bar" }')));
$result = \Vlaswinkel\Lua\LuaToPhpConverter::convertToPhpValue($parser->parse()); // returns the same as above
```

### Integration with JMS Serializer in Symfony2

[](#integration-with-jms-serializer-in-symfony2)

This serializer can easily be included into Symfony2 with JMSSerializer, by adding the following lines to your `services.yml`:

```
services:
    app.lua.serialization_visitor:
        class: Vlaswinkel\Lua\JMS\LuaSerializationVisitor
        arguments: ["@jms_serializer.naming_strategy"]
        tags:
            - { name: jms_serializer.serialization_visitor, format: lua }
    app.lua.deserialization_visitor:
        class: Vlaswinkel\Lua\JMS\LuaDeserializationVisitor
        arguments: ["@jms_serializer.naming_strategy"]
        tags:
            - { name: jms_serializer.deserialization_visitor, format: lua }
    app.lua.array_handler:
        class: Vlaswinkel\Lua\JMS\LuaArrayCollectionHandler
        tags:
            - { name: jms_serializer.subscribing_handler }
    app.lua.date_handler:
        class: Vlaswinkel\Lua\JMS\LuaDateHandler
        tags:
            - { name: jms_serializer.subscribing_handler }
    app.lua_constraint_violation_handler:
        class: Vlaswinkel\Lua\JMS\LuaConstraintViolationHandler
        tags:
            - { name: jms_serializer.subscribing_handler }
    app.lua.form_handler:
        class: Vlaswinkel\Lua\JMS\LuaFormHandler
        arguments: ["@translator"]
        tags:
            - { name: jms_serializer.subscribing_handler }
    app.lua_php_collection_handler:
        class: Vlaswinkel\Lua\JMS\LuaPhpCollectionHandler
        tags:
            - { name: jms_serializer.subscribing_handler }
```

If you want Symfony to recognize Lua as a request/response format, also add the following to your `config.yml`:

```
framework:
    request:
        formats:
            lua: ['application/x-lua', 'application/lua']

```

In this case I've added `application/x-lua` and `application/lua` as MIME-types, but as there's no standard for Lua content types, these can be whatever you like.

You can now use the format `lua` for serialization:

```
public function indexAction() {
    return $this->get('serializer')->serialize([ 'foo' => 'bar' ], 'lua');
}
```

Running tests
-------------

[](#running-tests)

You can run automated unit tests using [PHPUnit](http://phpunit.de) after installing dependencies:

```
vendor/bin/phpunit

```

License
-------

[](#license)

This library is licensed under the MIT license. See the [LICENSE](LICENSE) file for details.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~243 days

Total

4

Last Release

3108d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1112623?v=4)[Koen Vlaswinkel](/maintainers/koesie10)[@koesie10](https://github.com/koesie10)

---

Top Contributors

[![koesie10](https://avatars.githubusercontent.com/u/1112623?v=4)](https://github.com/koesie10 "koesie10 (14 commits)")

---

Tags

parserserializerserializationdeserializationlua

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/koesie10-lua-serializer/health.svg)

```
[![Health](https://phpackages.com/badges/koesie10-lua-serializer/health.svg)](https://phpackages.com/packages/koesie10-lua-serializer)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k260.4M292](/packages/masterminds-html5)[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k139.8M905](/packages/jms-serializer)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k91.4M664](/packages/jms-serializer-bundle)[flix-tech/avro-serde-php

A library to serialize and deserialize Avro records making use of the confluent schema registry

674.1M19](/packages/flix-tech-avro-serde-php)[laktak/hjson

JSON for Humans. A configuration file format with relaxed syntax, fewer mistakes and more comments.

86241.3k14](/packages/laktak-hjson)[metroplex-systems/edifact

Parser and Serializer for UN/EDIFACT messages

36408.3k](/packages/metroplex-systems-edifact)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
