PHPackages                             osmianski/super-objects - 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. osmianski/super-objects

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

osmianski/super-objects
=======================

A library providing a base class for creating super objects in PHP, the ones with lazy properties, elegant dependency injection, and more.

v0.2.0(3y ago)012MITPHPPHP ^8.2

Since Jan 28Pushed 3y ago1 watchersCompare

[ Source](https://github.com/osmianski/super-objects)[ Packagist](https://packagist.org/packages/osmianski/super-objects)[ Docs](https://github.com/osmianski/super-objects)[ RSS](/packages/osmianski-super-objects/feed)WikiDiscussions v0.1 Synced today

READMEChangelogDependencies (1)Versions (4)Used By (0)

Super objects
=============

[](#super-objects)

- [Introduction](#introduction)
- [Installation](#installation)
- [Usage](#usage)
    - [Basic syntax](#basic-syntax)
- [License](#license)

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

[](#introduction)

`osmianski/super-objects` package provides a base class for creating super objects in PHP. How a super object is different from its "traditional" counterpart:

1. Its "lazy" properties are computed only once and only when they are accessed. Lazy properties, among other things, make dependency injection blazing fast and elegant.
2. :) more features to come :)

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

[](#installation)

In the project directory, run:

```
composer require osmianski/super-objects
```

Usage
-----

[](#usage)

### Basic syntax

[](#basic-syntax)

As in the following example, extend the `SuperObject` class, define a property in the class comment, and getter that computes it:

```
use Osmianski\SuperObjects\SuperObject;
...
/**
 * @property string $message
 */
class Foo extends SuperObject
{
    protected function get_message(): string {
        return 'Hello, world!';
    }
}
```

The first time you access the property, it's created and assigned the value returned by the getter. On subsequent property access, the getter is not executed - the already stored value is returned:

```
$foo = new Foo();

// executing the getter
echo $foo->message;

// using the stored value
echo $foo->message;
```

Alternatively, pass property value in the constructor:

```
$foo = new Foo(['message' => 'custom message']);

// prints the custom message
echo $foo->message;
```

If you expect the value to be passed in the constructor, throw the `Required` exception:

```
use Osmianski\SuperObjects\Exceptions\Required;
...
/**
 * @property string $message
 */
class Foo extends SuperObject
{
    protected function get_message(): string {
        throw new Required(__METHOD__);
    }
}
```

License
-------

[](#license)

`osmianski/super-objects` package is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Total

4

Last Release

1251d ago

PHP version history (2 changes)v0.1.0PHP ^8.1

v0.2.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/70505ad13b7a3f67344988bd0f17f6a5c6bc29919300c7e12d937882eebc3080?d=identicon)[osmianski](/maintainers/osmianski)

---

Top Contributors

[![osmianski](https://avatars.githubusercontent.com/u/522822?v=4)](https://github.com/osmianski "osmianski (2 commits)")

---

Tags

lazypropertiesobjectsSuper

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/osmianski-super-objects/health.svg)

```
[![Health](https://phpackages.com/badges/osmianski-super-objects/health.svg)](https://phpackages.com/packages/osmianski-super-objects)
```

###  Alternatives

[cerbero/lazy-json

Framework-agnostic package to load JSONs of any dimension and from any source into Laravel lazy collections.

255320.3k1](/packages/cerbero-lazy-json)[ilya/belt

A handful of tools for PHP developers.

71020.9k1](/packages/ilya-belt)[lukascivil/treewalker

TreeWalker is a simple and small Library that will help you to work faster with manipulation of structures in PHP

731.1M7](/packages/lukascivil-treewalker)[kdyby/strict-objects

Simple trait to make your class strict, when calling or accessing undefined member (property or method).

321.7M18](/packages/kdyby-strict-objects)[minwork/array

Pack of advanced array functions specifically tailored for: associative (assoc) array, multidimensional array, array of objects and handling nested array elements

66268.2k5](/packages/minwork-array)[bruli/php-value-objects

PHP Value objects to use for DDD domains.

43321.9k8](/packages/bruli-php-value-objects)

PHPackages © 2026

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