PHPackages                             andrew-gos/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. andrew-gos/serializer

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

andrew-gos/serializer
=====================

A flexible and extensible serialization library for modern PHP applications

1.3.1(3mo ago)01781MITPHPPHP &gt;=8.2CI passing

Since Sep 3Pushed 3mo agoCompare

[ Source](https://github.com/CiBeRHeMuL/Serializer)[ Packagist](https://packagist.org/packages/andrew-gos/serializer)[ Docs](https://github.com/CiBeRHeMuL/Serializer)[ RSS](/packages/andrew-gos-serializer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (7)Used By (1)

Andrew-Gos/Serializer
=====================

[](#andrew-gosserializer)

[![Latest Stable Version](https://camo.githubusercontent.com/1f2748cad13326dc9ba6592b916ddcdb5c0556c883a929ec45dc86046cfa85ad/687474703a2f2f706f7365722e707567782e6f72672f616e647265772d676f732f73657269616c697a65722f76)](https://packagist.org/packages/andrew-gos/serializer)[![Total Downloads](https://camo.githubusercontent.com/78bf258d0d65c7466523a7796e610a7309b90acf1344d59c200db0726bf6c193/687474703a2f2f706f7365722e707567782e6f72672f616e647265772d676f732f73657269616c697a65722f646f776e6c6f616473)](https://packagist.org/packages/andrew-gos/serializer)[![Latest Unstable Version](https://camo.githubusercontent.com/01c656944b075b57d23b093e6c52e215f0f1a461c3577685c252524aa37e1bc6/687474703a2f2f706f7365722e707567782e6f72672f616e647265772d676f732f73657269616c697a65722f762f756e737461626c65)](https://packagist.org/packages/andrew-gos/serializer)[![License](https://camo.githubusercontent.com/e671582818c42ab23e3642e8e69c7c3fdb7f8029b38c13b94f66fbb006a24992/687474703a2f2f706f7365722e707567782e6f72672f616e647265772d676f732f73657269616c697a65722f6c6963656e7365)](https://packagist.org/packages/andrew-gos/serializer)[![PHP Version Require](https://camo.githubusercontent.com/09d062435af7293527a285482592d62e2bbeb17b55611c7461771e46660fb18f/687474703a2f2f706f7365722e707567782e6f72672f616e647265772d676f732f73657269616c697a65722f726571756972652f706870)](https://packagist.org/packages/andrew-gos/serializer)

A flexible and extensible serialization library for modern PHP applications.

This library provides a simple yet powerful way to convert complex PHP data structures, including objects and arrays, into various string formats like JSON and XML.

🚀 Key Features
--------------

[](#-key-features)

- **Flexible Architecture:** Easily add your own custom normalizers and encoders.
- **Object &amp; Array Support:** Correctly handles scalars, arrays, and objects.
- **Built-in Encoders:** Comes with ready-to-use encoders for JSON and XML.
- **Advanced XML Handling:** Automatically manages data duplication and circular references for both arrays and objects.
- **Modern PHP:** Built for PHP 8.2+ with strict typing.
- **No Side Effects:** The encoders are designed to be "pure" and will not modify your original input data.

🛠️ Installation
---------------

[](#️-installation)

The project requires PHP 8.2 or higher.

Install the library via [Composer](https://getcomposer.org/):

```
composer require andrew-gos/serializer
```

🏁 Quick Start
-------------

[](#-quick-start)

The `Serializer` is highly configurable and requires the registration of **normalizers** (to convert data into a serializable format) and **encoders** (to convert that format into a string).

### Example 1: Serializing an Array

[](#example-1-serializing-an-array)

```
