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

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

flolefebvre/serializer
======================

0.0.12(10mo ago)225MITPHP

Since Mar 27Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/flolefebvre/serializer)[ Packagist](https://packagist.org/packages/flolefebvre/serializer)[ RSS](/packages/flolefebvre-serializer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (5)Versions (13)Used By (0)

Flolefebvre Serializer
======================

[](#flolefebvre-serializer)

[![Packagist Version](https://camo.githubusercontent.com/c90ccbe821030e9ba2507c8761ac1d046e34c93d6824c08b71600dec937d16a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666c6f6c656665627672652f73657269616c697a65723f6c6162656c3d7061636b6167697374)](https://packagist.org/packages/flolefebvre/serializer)[![Downloads](https://camo.githubusercontent.com/6494bbc7794e649f4511d3acb8271f273175aa8c28fcbec791345020cb8ad527/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666c6f6c656665627672652f73657269616c697a6572)](https://packagist.org/packages/flolefebvre/serializer)[![License](https://camo.githubusercontent.com/c3e0f691797bf0f5cc6e3c88334a3b492db99fc499aaa668ede4918bd101f8d3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f666c6f6c656665627672652f73657269616c697a6572)](LICENSE)[![CI](https://github.com/flolefebvre/serializer/actions/workflows/tests.yml/badge.svg)](https://github.com/flolefebvre/serializer/actions/workflows/tests.yml)

A **zero‑boilerplate**, attribute‑driven serializer / DTO helper for **Laravel 10 &amp; 11**
*Built for PHP ≥ 8.2 — lighter than 20 KB.*

---

Table of Contents
-----------------

[](#table-of-contents)

- [Why another serializer?](#why-another-serializer)
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Quick start](#quick-start)
- [Advanced usage](#advanced-usage)
    - [Custom TypeCast](#custom-typecast)
    - [Arrays of DTOs](#arrays-of-dtos)
- [Performance &amp; Limitations](#performance--limitations)
- [Contributing](#contributing)
- [License](#license)

---

Why another serializer?
-----------------------

[](#why-another-serializer)

`flolefebvre/serializer` focuses on **simplicity and strictness**:

- DTOs are *just* classes extending [`Serializable`](src/Serializable.php).
- Validation occurs **before** the object exists — no invalid state can persist.
- No generated code or heavy reflection caches; your build stays ultra‑fast.

---

Features
--------

[](#features)

✅ Constructor‑promoted DTOs only✅ Automatic validation via `#[Rule]`✅ Pure attribute configuration✅ Typed arrays (`#[ArrayType]`)✅ Laravel DI &amp; Request auto‑binding✅ Custom type‑casts (`TypeCast` interface)✅ Eloquent JSON cast (single / list)✅ `JsonResponse` ready to return---

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

[](#requirements)

- PHP **8.2+**
- Laravel **10 / 11**
- `ext-json`

---

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

[](#installation)

```
composer require flolefebvre/serializer
```

---

Quick start
-----------

[](#quick-start)

Create a DTO:

```
