PHPackages                             onemoreangle/php-marshaller - 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. onemoreangle/php-marshaller

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

onemoreangle/php-marshaller
===========================

A small library with few required dependencies to serialize and deserialize PHP structures using optional attribute or annotation-based configuration

0336PHPCI passing

Since May 30Pushed 11mo ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

php-marshaller
==============

[](#php-marshaller)

[![tests](https://github.com/onemoreangle/php-marshaller/actions/workflows/ci.yml/badge.svg)](https://github.com/onemoreangle/php-marshaller/actions/workflows/ci.yml/badge.svg)

> **Warning**
> This project is in very early stages of development and should be considered experimental.

This is a small library with few required dependencies to serialize and deserialize PHP data structures using optional annotation-based configuration.

Current features
----------------

[](#current-features)

- JSON and YAML serialization and deserialization
- Optional attribute or annotation-based customization of (de)serialization
- Recursive deduction of property types and optional annotation-based target types
- Circular reference detection
- Support for both PHP 8 attributes and Doctrine annotations

Planned features
----------------

[](#planned-features)

- Support for other serialization formats, XML in particular
- More robust object instantiation capabilities
- User defined custom (de)serialization logic
- Performance optimizations
- Using getters and setters for data extraction and injection (as a default)

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

[](#installation)

For general use, install the library with composer using:

```
composer require onemoreangle/php-marshaller --no-dev
```

Development
-----------

[](#development)

Install the library using composer with dev dependencies:

```
composer require onemoreangle/php-marshaller
```

Usage
-----

[](#usage)

### Simple usage using default settings

[](#simple-usage-using-default-settings)

To serialize and deserialize, you can use any of the available serialization providers which come with defaults to read attributes/annotations. For example, to use the `Json` serialization provider with defaults:

```
use OneMoreAngle\Marshaller\Api\Json;

$data = new CustomClass();
$serialized = Json::marshal($data);
$deserialized = Json::unmarshal($json, CustomClass::class);
```

Other serialization providers for different formats will be added in the future.

### Customizing serialization

[](#customizing-serialization)

You can customize the serialization process by creating a `SerializerBuilder` and providing it with options. Often times you will want to use the default settings of the serialization provider and then customize them, which you can do as follows

```
use OneMoreAngle\Marshaller\Api\Json;
...
$serializer = Json::getDefaultSerializerBuilder()->withMetaExtractor(...)->build();
$data = $serializer->marshal($object);
```

### Attributes

[](#attributes)

You can use attributes to customize the (de)serialization process. For example, you can use the `Name` attribute to map a property to a different serialized name, the `Aliases` to map alternative serialized names to the property, the `Omit` attribute to omit a property from serialization, the `OmitEmpty` attribute to omit a property if it is empty, and the `TargetType` attribute to specify the type of the property to deserialize into. Let's look at an example:

```
use OneMoreAngle\Marshaller\Attribute\Aliases;
use OneMoreAngle\Marshaller\Attribute\Name;
use OneMoreAngle\Marshaller\Attribute\Omit;
use OneMoreAngle\Marshaller\Attribute\OmitEmpty;

class CustomClass {
    #[Name('custom_name')]
    #[Aliases(['alias1', 'alias2'])]
    #[OmitEmpty]
    public string $property;

    #[Omit]
    public string $property2;
}
```

When you serialize an instance of the above class as follows:

```
use OneMoreAngle\Marshaller\Api\Json;

$data = new CustomClass();
$data->property = 'test';
$data->property2 => 'test2';
$serialized = Json::marshal($data);
echo $serialized;
```

the output will be

```
{"custom_name":"test"}
```

When we deserialize with an aliased property in the JSON:

```
use OneMoreAngle\Marshaller\Api\Json;

$json = '{"alias2":"hello"}';
$deserialized = Json::unmarshal($json, CustomClass::class);
print_r($deserialized);
```

We get the following output:

```
CustomClass Object
(
    [property] => hello
)

```

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

[](#requirements)

- PHP &gt;= 8.2 (you can use either attributes (recommended) or install doctrine/annotations and use annotations instead)

Contributing
------------

[](#contributing)

Contributions are more than welcome! Please feel free to submit a pull request

License
-------

[](#license)

The php-marshaller library is released under the MIT License. See the [LICENSE](LICENSE) file for more details.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9eb88118cc923ecdc3876533235a1f30794daceaaeac087aced96a0a65726931?d=identicon)[onemoreangle](/maintainers/onemoreangle)

---

Top Contributors

[![onemoreangle](https://avatars.githubusercontent.com/u/109597356?v=4)](https://github.com/onemoreangle "onemoreangle (27 commits)")

### Embed Badge

![Health badge](/badges/onemoreangle-php-marshaller/health.svg)

```
[![Health](https://phpackages.com/badges/onemoreangle-php-marshaller/health.svg)](https://phpackages.com/packages/onemoreangle-php-marshaller)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

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

1.8k89.3M627](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M170](/packages/hassankhan-config)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

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