PHPackages                             scaleupstack/easy-object - 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. scaleupstack/easy-object

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

scaleupstack/easy-object
========================

Convenient object handling for a modern, defensive and strict style of programming in PHP without boilerplate code. E.g. default getters, typed properties, named/default constructors.

v0.3.0(6y ago)015BSD-3-ClausePHPPHP &gt;=7.2.0

Since Sep 6Pushed 6y ago1 watchersCompare

[ Source](https://github.com/scaleupstack/easy-object)[ Packagist](https://packagist.org/packages/scaleupstack/easy-object)[ RSS](/packages/scaleupstack-easy-object/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

ScaleUpStack/EasyObject
=======================

[](#scaleupstackeasyobject)

This library provides convenient object handling for a modern, defensive and strict style of programming in PHP.

This library reduces boilerplate code dramatically, and offers features that PHP does not support (yet), e.g.:

- structs,
- immutable objects,
- typed properties, including union types,
- default getters,
- simplified setup of test fixtures,
- no dynamic/un-defined properties in objects

This library is based on [scaleupstack/metadata](https://github.com/scaleupstack/metadata) and [scaleupstack/reflection](https://github.com/scaleupstack/reflection).

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

[](#installation)

Use [Composer](https://getcomposer.org) to install this library:

```
$ composer require scaleupstack/easy-object

```

Introduction
------------

[](#introduction)

The main motivation while developing this library, is to simplify modelling of your business domain in the sense of Domain-Driven Design (DDD), Event-Sourcing (ES) and Command Query Responsibility Segregation (CQRS). But of course, you are not limited to that.

Currently, you can enhance your objects with default features like:

- standard getters,
- standard constructors and named constructors (a.k.a. factory methods),
- typed properties, including union types, and
- a simplified and maintainable set-up of fixtures in your tests.

And it's very easy to implement additional features.

To understand the usage of the library, there are three things:

- The library offers magic behaviour, e.g. check-out [src/Magic/VirtualGetter.php](https://github.com/scaleupstack/easy-object/tree/master/src/Magic/VirtualGetter.php) or [src/Magic/NamedConstructor.php](https://github.com/scaleupstack/easy-object/tree/master/src/Magic/NamedConstructor.php).
- Next you need some trait where you include the relevant features, e.g. [src/Traits/FixtureBuilderTrait.php](https://github.com/scaleupstack/easy-object/tree/master/src/Traits/FixtureBuilderTrait.php). To get an idea, how to include static and non-static methods, checkout [tests/Resources/Magic/ClassForNamedConstructorTesting.php](https://github.com/scaleupstack/easy-object/tree/master/tests/Resources/Magic/ClassForNamedConstructorTesting.php). (Even the magic is not included as trait here, that is not a big deal.)
- Finally you need to annotate your entities and use the correct trait, e.g. as done in [tests/Resources/Traits/EntityForTesting.php](https://github.com/scaleupstack/easy-object/tree/master/tests/Resources/Traits/EntityForTesting.php), [tests/Resources/Traits/FixtureBuilderForTesting.php](https://github.com/scaleupstack/easy-object/tree/master/tests/Resources/Traits/FixtureBuilderForTesting.php), or [tests/Resources/Magic/ClassForDispatcherTesting.php](https://github.com/scaleupstack/easy-object/tree/master/tests/Resources/Magic/ClassForDispatcherTesting.php).

Features, considered for the future, include:

- preventing dynamic/undefined properties,
- serialization,
- working on evolving data structures without updating all clients (e.g. for new versions of domain events),
- validation?
- virtual setters? (Easy; but don't you want to write intention-revealing methods to transform the state of your objects?)
- read-only properties? (I'm comfortable with default getters.)

Checkout \[src/Traits/\] to find out, how it works. (I'm not sure if I want to deliver these traits in the future. It might be better to provide them as examples. So it might be a good idea to copy these traits in your project; or at least create your project-specific traits that include these traits.)

This library is based on [scaleupstack/metadata](https://github.com/scaleupstack/metadata) (including \[scaleupstack/annotations\]), and [scaleupstack/reflection](https://github.com/scaleupstack/reflection). Via extension points in this library, and in [scaleupstack/metadata](https://github.com/scaleupstack/metadata) you can add additional meta-programming for your use-cases.

TODO: TBD

Current State
-------------

[](#current-state)

This library will be developed further in the context of an internal project. I do not expect big refactorings or BC breaks. (One minor BC issue might be the removal of `src/Traits/` as mentioned above.)

If you are missing anything, feel free to contact me, or create a pull request.

Please, feel free to contact me, when you evaluate this library. I'd be happy to discuss ideas, or will be more sensible when breaking things.

Contribute
----------

[](#contribute)

Thanks that you want to contribute to ScaleUpStack/EasyObject.

- Report any bugs or issues on the [issue tracker](https://github.com/scaleupstack/easy-object/issues).
- Get the source code from the [Git repository](https://github.com/scaleupstack/easy-object).

License
-------

[](#license)

Please check [LICENSE.md](LICENSE.md) in the root dir of this package.

Copyright
---------

[](#copyright)

ScaleUpVentures Gmbh, Germany
Thomas Nunninger
[www.scaleupventures.com](https://www.scaleupventures.com/)

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

Total

3

Last Release

2441d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/691747f4cbd1862bd8f73353b9958caff9afc5fa6d2ee3a3c9f411d822cee77d?d=identicon)[ScaleUpStack](/maintainers/ScaleUpStack)

---

Top Contributors

[![ThomasNunninger](https://avatars.githubusercontent.com/u/280145?v=4)](https://github.com/ThomasNunninger "ThomasNunninger (43 commits)")

---

Tags

objectboilerplateunion typestyped propertiestyped propertydefault constructorsnamed constructorsdefault gettersfixture setupno boilerplate

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/scaleupstack-easy-object/health.svg)

```
[![Health](https://phpackages.com/badges/scaleupstack-easy-object/health.svg)](https://phpackages.com/packages/scaleupstack-easy-object)
```

###  Alternatives

[myclabs/deep-copy

Create deep copies (clones) of your objects

8.9k849.8M169](/packages/myclabs-deep-copy)[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[yzen.dev/plain-to-class

Class-transformer to transform your dataset into a structured object

16293.9k6](/packages/yzendev-plain-to-class)[jasny/dotkey

Dot notation access for objects and arrays

14219.5k6](/packages/jasny-dotkey)[peridot-php/object-path

A string syntax to fetch values from array and object hierarchies

1053.6k1](/packages/peridot-php-object-path)

PHPackages © 2026

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