PHPackages                             kariricode/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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. kariricode/serializer

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

kariricode/serializer
=====================

Multi-format serialization engine for PHP 8.4+ — JSON, XML, CSV, QueryString, #\[Serialize\] attributes, powered by kariricode/property-inspector. ARFA 1.3.

v1.1.0(3mo ago)00MITPHPPHP ^8.4CI passing

Since Mar 5Pushed 3mo agoCompare

[ Source](https://github.com/KaririCode-Framework/kariricode-serializer)[ Packagist](https://packagist.org/packages/kariricode/serializer)[ Docs](https://kariricode.org)[ RSS](/packages/kariricode-serializer/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

KaririCode Serializer
=====================

[](#kariricode-serializer)

[![PHP 8.4+](https://camo.githubusercontent.com/270717987f5341772d79b57567226e54ed27b2d4199bbdc98a96e2edf24902fa/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342532422d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://www.php.net/)[![CI](https://github.com/KaririCode-Framework/kariricode-serializer/actions/workflows/ci.yml/badge.svg)](https://github.com/KaririCode-Framework/kariricode-serializer/actions/workflows/ci.yml)[![License: MIT](https://camo.githubusercontent.com/1e64768fef09f35b66921728160f533208fd2e3e792a2755187d16c25d535511/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d3232633535652e737667)](LICENSE)[![PHPStan Level 9](https://camo.githubusercontent.com/a812723b363d3726b682e5d739e91f2ade163846054ce3797b9085b84cc61806/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230392d344634364535)](https://phpstan.org/)[![Tests](https://camo.githubusercontent.com/08d2937653affbcd0fe775099a7eab50cee062d0da34621cd89be4986cbde132/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54657374732d3130302532355f706173732d323263353565)](tests/)[![Encoders](https://camo.githubusercontent.com/00704b61f35adab46076e2c55439e6da5cd847ead012b58f8f15b3ec5a4c0e79/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f456e636f646572732d342d323263353565)](https://kariricode.org)[![Zero Runtime Deps](https://camo.githubusercontent.com/916f423d5d66f44a02065cf0a08086d37e0f9adee837ba0e37f6b6701a0c2504/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52756e74696d65253230446570732d302d323263353565)](composer.json)[![ARFA](https://camo.githubusercontent.com/708efab30524ab8fd4e0413edfb4378bb863a71559c4a9b59cdcb7b0ab6f65c0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f415246412d312e332d6f72616e6765)](https://kariricode.org)[![KaririCode Framework](https://camo.githubusercontent.com/bd3e3709bf161ac982b76f7afd06c39afe478d15f2b5e1d47df8606b5c9c03f0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4b6172697269436f64652d4672616d65776f726b2d6f72616e6765)](https://kariricode.org)

**Multi-format serialization for PHP 8.4+ — JSON, XML, CSV, QueryString, zero dependencies.**

[Installation](#installation) · [Quick Start](#quick-start) · [Attribute-Driven](#attribute-driven-dto-serialization) · [All Encoders](#all-4-encoders) · [Architecture](#architecture)

---

The Problem
-----------

[](#the-problem)

Multi-format serialization for PHP always pulls in heavy dependencies or loses the data contract:

```
// symfony/serializer: 7+ packages, complex config, annotation magic
// league/fractal: transformer boilerplate, no attribute support
// json_encode/decode alone: no groups, no field renaming, no XML/CSV

// Switching from JSON to XML means rewriting your serialization layer entirely.
```

The Solution
------------

[](#the-solution)

```
use KaririCode\Serializer\Provider\SerializerServiceProvider;

$engine = (new SerializerServiceProvider())->createEngine();

// One API, four formats — swap format string to change output
$json = $engine->serialize(['name' => 'Walmir', 'age' => 30], 'json');
$xml  = $engine->serialize(['name' => 'Walmir', 'age' => 30], 'xml', ['root' => 'user']);
$csv  = $engine->serialize([['name' => 'Walmir', 'age' => 30]], 'csv');
$qs   = $engine->serialize(['name' => 'Walmir', 'age' => 30], 'query_string');

// RFC 8259 (JSON) · RFC 4180 (CSV) · RFC 3986 (URL) — built-in compliance
```

---

Requirements
------------

[](#requirements)

RequirementVersionPHP8.4 or higherext-simplexmlBuilt-in (required for XML)kariricode/property-inspector^2.0---

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

[](#installation)

```
composer require kariricode/serializer
```

---

Quick Start
-----------

[](#quick-start)

```
