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

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

moirei/objects
==============

Simple data &amp; array objects.

1.1.0(2y ago)0132MITPHPPHP ^8.0

Since Jul 12Pushed 2y agoCompare

[ Source](https://github.com/moirei/objects)[ Packagist](https://packagist.org/packages/moirei/objects)[ RSS](/packages/moirei-objects/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (3)Used By (0)

moirei/objects
==============

[](#moireiobjects)

A package for simple and lightweight data/array objects.

Install
-------

[](#install)

```
composer require moirei/objects
```

> Note: this package does not automatically cast nested objects.

Usage
-----

[](#usage)

### Object

[](#object)

```
final class User extends BaseObject
{
  public string $name;
  public string $email;
}
```

```
$user = new User([
  'name' => 'Joe',
  'email' => 'top_lad@mail.com',
]);

// or

$user = User::make([
  'name' => 'Joe',
  'email' => 'top_lad@mail.com',
]);

// or

$user = User::make();
$user->name = 'Joe';
$user['email'] = 'top_lad@mail.com';

...

dump($user->toArray());
dump($user);
```

Accessing or mutation undefined properties throws an exception.

### Non-strict Object

[](#non-strict-object)

```
/**
 * @property string|null $city
 */
final class User extends BaseObject
{
  protected $strict = false;
  public string $name;
  public string $email;
}
```

```
$user = User::make([
  'name' => 'Joe',
  'email' => 'top_lad@mail.com',
]);

...
$user->city = 'Adelaide';
```

Accessing or mutation undefined properties is allowed.

Rationale
---------

[](#rationale)

If you're no longer comfortable passing or returning data as untyped array to your app logic, and want a simple solution, then this package is for you.

For the below example, we can be confident of the data type being returned from the action.

```
final class InstallationStatus extends BaseObject
{
    public bool $completed = false;
    public ?string $key;
    /** @var string[] */
    public array $errors = [];
}
```

```
class InstallAppAction{
  use AsAction;

  public function handle(string $code): InstallationStatus{
    $status = InstallationStatus::make();

    try{
      // logic
      $status->completed = true;
      $status->key = '...';
    }catch(\Exception $e){
      $status->errors = [
        $e->getMessage()
      ];
    }

    return $status;
  }
}
```

License
-------

[](#license)

[MIT](./LICENSE)

Special thanks to Eduardo San Martin Morote ([posva](https://github.com/posva)) for [encoding utlities](https://github.com/vuejs/vue-router-next/blob/v4.0.1/src/encoding.ts)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community6

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

Total

2

Last Release

1038d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7ac6a15a7b2f9055a98e4419e0d2820f72db3567706837ec388baee535d3e3e7?d=identicon)[moirei](/maintainers/moirei)

---

Top Contributors

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

---

Tags

laravelarraydataobject

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[illuminatech/array-factory

Allows DI aware object creation from array definition

2159.6k6](/packages/illuminatech-array-factory)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2516.7k](/packages/iteks-laravel-enum)[xefi/faker-php-laravel

Faker php integration with laravel

1915.1k](/packages/xefi-faker-php-laravel)[jaybizzle/hasmeta

Access model meta data as if it was a property on your model

291.9k](/packages/jaybizzle-hasmeta)

PHPackages © 2026

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