PHPackages                             cupcoffee/reify - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. cupcoffee/reify

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

cupcoffee/reify
===============

A mapping library

0.4(4y ago)031PHP

Since Jan 9Pushed 4y agoCompare

[ Source](https://github.com/leroy/Reify)[ Packagist](https://packagist.org/packages/cupcoffee/reify)[ RSS](/packages/cupcoffee-reify/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (6)Used By (0)

Reify
=====

[](#reify)

Reify is a small package used to hydrate objects. This can be useful when implementing API clients or creating abstraction layers in your application.

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

[](#installation)

*Insert warning about production usage here*

`composer require reify/reify:"dev-master"`

Getting started
---------------

[](#getting-started)

Let's say you have a dataset containing information about a person.

```
{
	"name": "Leroy",
	"profession": "Developer",
	"colleagues": [
		{
			"name": "Peter",
			"profession": "Developer"
		},
		{
			"name": "Sandra",
			"profession": "Developer"
		}
	],
	"spouse": null
}
```

You want to use this data in your application, however just using `json_decode` would result in a plain object with no typing and no way to add some functionality to them.

Reify can automatically map the data to any class you want. Let's try to map our data by using our Person class which i defined below.

```
use Reify\Reify;

$person = Reify::json($data)->to(Person::class);
```

```
use Reify\Attributes\Construct;
use Reify\Attributes\Type;

class Person {
    public string $name;

    #[Construct]
    public Profession $profession;

    #[Type(Person::class)]
    public array $colleagues;

    public ?Person $spouse;

    public object $meta;
}
```

Neat right? Let's dissect what's happening here.

```
class Person {
    /**
     * Using PHP 8 syntax we can define a type for each property
     * Reify supports all scalar values and custom types defined by you
     */
    public string $name;

    /**
     * If you have a single value that needs to be mapped to a type
     * You can use the Construct attribute. This will call the constructor with the value instead of mapping it.
     */
    #[Construct]
    public Profession $profession;

    /**
     * Unfortunately PHP does not have Generics.
     * We can however still define a type using the Type attribute.
 *   * Reify will try to map each value in the list to the given value
     */
    #[Type(Person::class)]
    public array $colleagues;

    /**
    * Not sure if the data is available?
    * Reify will take your nullables in to account.
    */
    public ?Person $spouse;

    /**
    * You don't know what the data is going to look like?
    * Reify supports mapping to plain objects aswell.
    */
    public object $meta;
}
```

Conclusion
----------

[](#conclusion)

Reify is a concept I've been tinkering with over the years. It's a simple concept that I use very often in the projects I am working on.

This package is build with PHP 8 features for me to learn about them and fiddling with the new Attributes. Turns out I love metaprogramming and creating developer tools with them.

Building Reify i also had a chance to meet [PestPHP](https://pestphp.com/) and learn more about writing tests for my code.

Running tests
-------------

[](#running-tests)

`vendor/bin/pest`

Alternatives
------------

[](#alternatives)

If you're looking for production worthy recommendations that I use myself please see below:

-  (JSON)
-  (XML)

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community3

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

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

Total

4

Last Release

1463d ago

### Community

---

Top Contributors

[![leroy](https://avatars.githubusercontent.com/u/3531171?v=4)](https://github.com/leroy "leroy (13 commits)")

### Embed Badge

![Health badge](/badges/cupcoffee-reify/health.svg)

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

###  Alternatives

[usamamuneerchaudhary/commentify

Easy Laravel Livewire Comments with TailwindCSS UI

23214.3k](/packages/usamamuneerchaudhary-commentify)

PHPackages © 2026

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