PHPackages                             jgswift/restructr - 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. jgswift/restructr

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

jgswift/restructr
=================

PHP 5.5+ domain component foundation

0.1.22(11y ago)02261MITPHPPHP &gt;=5.5

Since Jan 15Pushed 11y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (1)Versions (3)Used By (1)

restructr
=========

[](#restructr)

domain component foundation

[![Build Status](https://camo.githubusercontent.com/58b1ff9b6e284d8b425f0bd8c8d6c72de32e65fb9092d427aac109e802a62615/68747470733a2f2f7472617669732d63692e6f72672f6a6773776966742f7265737472756374722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/jgswift/restructr)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f4b58afca34a15d0b6b084994c088dce5e01eb77aabdd5ba35e923325c603436/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a6773776966742f7265737472756374722f6261646765732f7175616c6974792d73636f72652e706e673f733d34633134333363643436383634343065306138613265623261306433616163396432613632333337)](https://scrutinizer-ci.com/g/jgswift/restructr/)[![Latest Stable Version](https://camo.githubusercontent.com/4dac1aa0d4060e8a4b3c6da34a0dbb742806256fe91ad36dd3120547a8471d21/68747470733a2f2f706f7365722e707567782e6f72672f6a6773776966742f7265737472756374722f762f737461626c652e737667)](https://packagist.org/packages/jgswift/restructr)[![License](https://camo.githubusercontent.com/eefd3e582d4c0635d09ef6a70eb583ef2564ec05d5179d79628b4037d9420995/68747470733a2f2f706f7365722e707567782e6f72672f6a6773776966742f7265737472756374722f6c6963656e73652e737667)](https://packagist.org/packages/jgswift/restructr)

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

[](#installation)

Install via cli using [composer](https://getcomposer.org/):

```
php composer.phar require jgswift/restructr:0.1.*
```

Install via composer.json using [composer](https://getcomposer.org/):

```
{
    "require": {
        "jgswift/restructr": "0.1.*"
    }
}
```

Dependency
----------

[](#dependency)

- [php](http://php.net) 5.5+

Description
-----------

[](#description)

restructr provides a set of foundational component abstractions in order to facilitate [domain driven development](https://en.wikipedia.org/wiki/Domain-driven_design) in PHP. With no exception, the component foundation classes are composed at compile-time by traits, allowing a flexible approach that requires little imposition on an already existing domain model. restructr provides these domain driven abstractions from both array-first or object-first perspectives. restructr assumes very little about any given domains implementation and allows significant customization of existing functionality.

Component Abstractions
----------------------

[](#component-abstractions)

- `Entity` - A single identifiable component
- `Collection` - A collection of `Entity` components
- `ValueArray` - An immutable `ArrayAccess` (`offsetGet`, `offsetSet`, etc..)
- `ValueObject` - An immutable `ObjectAccess` (`__get`, `__set`, etc..)
- `CollectionEntity` - An `Entity` component that also accepts/serializes an inner `Collection`
- `CollectionIterator` - A `Collection` of non-accessable but iterable `Entity` components.
- `EntityIterator` - A `Entity` of non-accessable but iterable domain data

As mentioned above, it is possible to include these concepts into an already existing domain without extending the provided abstractions. Nearly all abstractions are provided as composable traits that may be used or combined in any number of ways.

Trait Extensions
----------------

[](#trait-extensions)

These traits are included to customize domain implementations in various ways. Some of these are foundational to the provided component abstractions, while others may be excluded or included on a per-domain basis.

- `ArrayAccess` - SPL `ArrayAccess` implementation using local domain data
- `ArrayAggregate` - SPL `IteratorAggregate` implementation using local domain data
- `ArrayAttributable` - `ArrayAccess` key restraints as defined by `getAttributes` method
- `ArrayEnumerable` - `Enumerable` implementation to retrieve local domain data
- `ArrayEnumerableAggregate` - SPL `IterateAggregate` implementation using `Enumerable` data
- `ArrayImmutable` - `ArrayAccess` implementation that disallows mutation (`offsetSet`, `offsetUnset`)
- `ArrayIterator` - SPL `Iterator` implementation using local domain data
- `Countable` - SPL `Countable` implementation using local domain data
- `ObjectAccess` - Object magic implementation based on `ArrayAccess` trait
- `ObjectAttributable` - `ObjectAccess` property restraints as defined by `getAttributes` method
- `ObjectEnumerable` - `ArrayEnumerable` alias
- `ObjectImmutable` - `ObjectAccess` implementation that disallows property mutation (`__set`, `__unset`)
- `RecursiveArrayIterator` - SPL `RecursiveIterator` implementation that uses RecursiveArrayIterator from SPL
- `RecursiveIterator` - Minimal SPL `RecursiveIterator` implementation
- `RecursiveSerializer` - `Enumerable` implementation that recursively converts domain data to an array

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

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

Total

2

Last Release

4134d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e60e96f18d8a9dc2aff1363eedbaf210acc96666e7497d2a83d5a416ef397295?d=identicon)[jgswift](/maintainers/jgswift)

---

Top Contributors

[![jgswift](https://avatars.githubusercontent.com/u/661738?v=4)](https://github.com/jgswift "jgswift (9 commits)")

---

Tags

phpinterfacetraitddddomain driven development

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jgswift-restructr/health.svg)

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

###  Alternatives

[kkszymanowski/traitor

Add a trait use statement to existing PHP class

1305.2M16](/packages/kkszymanowski-traitor)[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)

PHPackages © 2026

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