PHPackages                             leocavalcante/ippo - 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. leocavalcante/ippo

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

leocavalcante/ippo
==================

Immutable Plain-old PHP Objects

2881PHP

Since Feb 27Pushed 7y ago1 watchersCompare

[ Source](https://github.com/leocavalcante/ippo)[ Packagist](https://packagist.org/packages/leocavalcante/ippo)[ RSS](/packages/leocavalcante-ippo/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

I.P.P.O [![CircleCI](https://camo.githubusercontent.com/532661e401efe53972ff7e5c65f1b45ea0af6ab57de40bae888435ff6b00b3aa/68747470733a2f2f636972636c6563692e636f6d2f67682f6c656f636176616c63616e74652f6970706f2e7376673f7374796c653d737667)](https://circleci.com/gh/leocavalcante/ippo)
=======================================================================================================================================================================================================================================================================================

[](#ippo-)

- Immutable - *Uses `with`s instead of setters*
- Statically-typed - *Your tooling loves it*
- Cloneable - *No reference sharing*
- Serializable - *To JSON, to Array and to String*

― Auto-generated Plain-old PHP Objects.

#### 🛡️ Both lib's source code and it's generated code are verifiable by [Phan](https://github.com/phan/phan) on its strictest level.

[](#️-both-libs-source-code-and-its-generated-code-are-verifiable-by-phan-on-its-strictest-level)

Usage
-----

[](#usage)

A definition file looks like:

```
namespace: App

definitions:
  - User:
    id: int
    name: string
    email: string
    isAdmin: [bool, 'false']
    birthDate: [?\DateTime, 'null']
```

It's self explanatory, it declares an `User` class on the `App` namespace with `member: type` or `member: [type, default]`. Simple like that.

You're encoraged to install it as a development dependency in your project:

```
$ composer install --dev leocavalcante/ippo dev-master
```

It will place a binary file at `vendor/bin` that requires only two arguments: the definition file and the output directory.

```
$ vendor/bin/ippo definitions.yml src/generated/
```

Output examples
---------------

[](#output-examples)

From the definitions above, you get an `User` class:

```
class User implements \JsonSerializable
```

With a construtor like:

```
public function __construct(
    int $id,
    string $name,
    string $email,
    bool $isAdmin = false,
    ?\DateTime $birthDate = null
) {
    $this->id = $id;
    $this->name = $name;
    $this->email = $email;
    $this->isAdmin = $isAdmin;
    $this->birthDate = $birthDate;
}
```

Getters and withs for each declared attribute, like:

```
public function getName(): string
{
    return $this->name;
}

public function withName(string $name): User
{
    return new User(
        $this->id,
        $name,
        $this->email,
        $this->isAdmin,
        $this->birthDate
    );
}
```

And serialization methods like `toArray`:

```
public function toArray(): array
{
    return [
        'id' => $this->id,
        'name' => $this->name,
        'email' => $this->email,
        'is_admin' => $this->isAdmin,
        'birth_date' => $this->birthDate,
    ];
}
```

Or `toString()`:

```
public function toString()
{
    $id = json_encode($this->id);
    $name = json_encode($this->name);
    $email = json_encode($this->email);
    $isAdmin = json_encode($this->isAdmin);
    $birthDate = json_encode($this->birthDate);

    return "User(\n\tid => {$id};\n\tname => {$name};\n\temail => {$email};\n\tisAdmin => {$isAdmin};\n\tbirthDate => {$birthDate};\n)";
}
```

Con·ven·ient factory methods like `fromArray` and `fromJson`:

```
static public function fromArray(array $source): User
{
    return new User(
        $source['id'] ?? null,
        $source['name'] ?? null,
        $source['email'] ?? null,
        $source['is_admin'] ?? false,
        $source['birth_date'] ?? null,
    );
}

static public function fromJson(string $json): User
{
    $source = json_decode($json, true);

    if (false === $source) {
        throw new \InvalidArgumentException('JSON decode error: '.json_last_error_msg());
    }

    if (!is_array($source)) {
        throw new \InvalidArgumentException('Your JSON didnt decoded to an array');
    }

    return User::fromArray($source);
}
```

#### [Check out the complete output here](https://github.com/leocavalcante/ippo/blob/master/example/User.php)

[](#check-out-the-complete-output-here)

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 92.3% 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/940717934113da7abe00589e87cfde6f34496f039bcd3fc6ce4a33f5f415d4ac?d=identicon)[leocavalcante](/maintainers/leocavalcante)

---

Top Contributors

[![leocavalcante](https://avatars.githubusercontent.com/u/183722?v=4)](https://github.com/leocavalcante "leocavalcante (24 commits)")[![bestform](https://avatars.githubusercontent.com/u/129437?v=4)](https://github.com/bestform "bestform (2 commits)")

---

Tags

auto-generatedcloneableimmutableobjectsphpserializable

### Embed Badge

![Health badge](/badges/leocavalcante-ippo/health.svg)

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

PHPackages © 2026

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