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

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

byjg/serializer
===============

A powerful multi-format serialization library that converts objects, arrays, and data between JSON, XML, YAML, CSV, PHP serialize, and plain text formats with intelligent property mapping and transformation

6.0.1(4mo ago)6189.3k↓41.5%25MITPHPPHP &gt;=8.3 &lt;8.6CI failing

Since May 11Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/byjg/php-serializer)[ Packagist](https://packagist.org/packages/byjg/serializer)[ GitHub Sponsors](https://github.com/byjg)[ RSS](/packages/byjg-serializer/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (6)Versions (18)Used By (5)

   sidebar\_key serializer   tags    php

 text-manipulation

    Multi-Format Serializer
=======================

[](#multi-format-serializer)

A powerful multi-format serialization library that converts objects, arrays, and data between JSON, XML, YAML, CSV, PHP serialize, and plain text formats with intelligent property mapping and transformation.

[![Sponsor](https://camo.githubusercontent.com/fab14b7f7f475072ada0473f193d6f322561fd4a2958e0cc89910d053347cf27/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53706f6e736f722d2532336561346161613f6c6f676f3d67697468756273706f6e736f7273266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d306431313137)](https://github.com/sponsors/byjg)[![Build Status](https://github.com/byjg/php-serializer/actions/workflows/phpunit.yml/badge.svg?branch=master)](https://github.com/byjg/php-serializer/actions/workflows/phpunit.yml)[![Opensource ByJG](https://camo.githubusercontent.com/425c1bbccc0f292bf4d20569ae74a6b2e384fd648f1af8911bc61de9a8dcfc0b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6f70656e736f757263652d62796a672d737563636573732e737667)](http://opensource.byjg.com)[![GitHub source](https://camo.githubusercontent.com/88e61eb211719144efdd570290a0456b6e13099c2df8d973f1bb43fe33bf0039/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4769746875622d736f757263652d696e666f726d6174696f6e616c3f6c6f676f3d676974687562)](https://github.com/byjg/php-serializer/)[![GitHub license](https://camo.githubusercontent.com/c47de60c87efb88af8b6f531686882bded112a7b7099e35bc62c97dd52735c83/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f62796a672f7068702d73657269616c697a65722e737667)](https://opensource.byjg.com/opensource/licensing.html)[![GitHub release](https://camo.githubusercontent.com/c73cc05dc35220ab00d377ee6b556f6375c0554aa5fd87c94ecf4fd64ea023ab/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f62796a672f7068702d73657269616c697a65722e737667)](https://github.com/byjg/php-serializer/releases/)

Features
--------

[](#features)

- **Format Conversion**: Transform objects to JSON, XML, YAML, or Arrays, and back again
- **Property Control**: Filter, transform, and manipulate object properties during conversion
- **Object Mapping**: Copy properties between different object structures with intelligent mapping
- **Property Pattern Matching**: Customize how properties are matched and transformed
- **Attribute Support**: Process PHP attributes during serialization and deserialization
- **Type Safety**: Maintain data types during transformations

Quick Examples
--------------

[](#quick-examples)

### Convert an object to JSON

[](#convert-an-object-to-json)

```
$object = new MyClass();
$json = \ByJG\Serializer\Serialize::from($object)
    ->toJson();
```

### Copy properties between objects

[](#copy-properties-between-objects)

```
$source = ["id" => 1, "name" => "John"];
$target = new User();
\ByJG\Serializer\ObjectCopy::copy($source, $target);
```

### Create a copyable object

[](#create-a-copyable-object)

```
class User implements \ByJG\Serializer\ObjectCopyInterface
{
    use \ByJG\Serializer\ObjectCopyTrait;

    public $id;
    public $name;

    // Automatically inherits copyFrom() and copyTo() methods
}
```

Documentation
-------------

[](#documentation)

### Core Components

[](#core-components)

ComponentDescriptionLink**Serialize**Core component for converting objects between formats[Documentation](docs/serialize.md)**ObjectCopy**Final utility class for copying properties between objects[Documentation](docs/objectcopy.md)**ObjectCopyTrait**Trait implementing copyable object functionality[Documentation](docs/objectcopytrait.md)**ObjectCopyInterface**Interface for implementing copyable objects[Documentation](docs/objectcopyinterface.md)**BaseModel**Abstract base class with object copying functionality[Documentation](docs/basemodel.md)**DirectTransform**Basic property handler for direct transformations in ObjectCopy[Documentation](docs/directtransform.md)### Guides

[](#guides)

- **[Formatters](docs/formatters.md)** - JSON, XML, YAML, CSV, and Plain Text output formatting
- **[Property Handlers](docs/propertyhandlers.md)** - Transform property names and values during copying
- **[Advanced Usage](docs/advanced-usage.md)** - Performance optimization, security, and complex patterns
- **[Integration Examples](docs/integration-examples.md)** - Framework integration (Symfony, Laravel, Doctrine, etc.)
- **[ByJG Ecosystem](docs/byjg-ecosystem.md)** - How Serializer integrates with other ByJG components
- **[Troubleshooting](docs/troubleshooting.md)** - Common issues and solutions

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

[](#installation)

```
composer require "byjg/serializer"
```

Testing
-------

[](#testing)

```
./vendor/bin/phpunit
```

Dependencies
------------

[](#dependencies)

 ```
flowchart TD
    byjg/serializer --> ext-json
    byjg/serializer --> symfony/yaml
    byjg/serializer --> ext-simplexml
```

      Loading ---

[Open source ByJG](http://opensource.byjg.com)

###  Health Score

60

—

FairBetter than 98% of packages

Maintenance78

Regular maintenance activity

Popularity39

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity89

Battle-tested with a long release history

 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 ~223 days

Recently: every ~122 days

Total

17

Last Release

126d ago

Major Versions

1.0.7 → 4.9.02023-05-21

4.9.2 → 5.0.x-dev2024-10-27

5.0.0 → 6.0.02025-11-26

PHP version history (6 changes)1.0.0PHP &gt;=5.4.0

1.0.3PHP &gt;=5.5

4.9.0PHP &gt;=5.6

4.9.1PHP &gt;=7.4

5.0.x-devPHP &gt;=8.1 &lt;8.4

6.0.0PHP &gt;=8.3 &lt;8.6

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/981924?v=4)[Joao Gilberto Magalhaes](/maintainers/byjg)[@byjg](https://github.com/byjg)

---

Top Contributors

[![byjg](https://avatars.githubusercontent.com/u/981924?v=4)](https://github.com/byjg "byjg (136 commits)")

---

Tags

bindingjsonphpserializerxml

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103519.9k53](/packages/friendsoftypo3-content-blocks)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)[aeliot/todo-registrar

Register TODOs from source code in issue tracker

153.0k](/packages/aeliot-todo-registrar)

PHPackages © 2026

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