PHPackages                             northwoods/entity-proxy - 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. northwoods/entity-proxy

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

northwoods/entity-proxy
=======================

A hydrating proxy for objects with private properties

2.1.0(7y ago)31.7kMITPHPPHP &gt;=7.2

Since May 4Pushed 7y ago1 watchersCompare

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

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

Northwoods Entity Proxy
=======================

[](#northwoods-entity-proxy)

[![Become a Supporter](https://camo.githubusercontent.com/28a4011c597c1f2866c7419fcefd80ec11a8591e34f94612242c09e86e8a30dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617472656f6e2d73706f6e736f722532306d652d6536343631612e737667)](https://www.patreon.com/shadowhand)[![Latest Stable Version](https://camo.githubusercontent.com/9fcc8c309bca268e25ee1e46045c273581f359f1965dbb5231f5fb4e3b70301f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6f727468776f6f64732f656e746974792d70726f78792e737667)](https://packagist.org/packages/northwoods/entity-proxy)[![License](https://camo.githubusercontent.com/ad36e38e99874c6307f3346fc19d739b5ad556b9586ef9f55e7b8d160e32aedf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e6f727468776f6f64732f656e746974792d70726f78792e737667)](https://github.com/northwoods/entity-proxy/blob/master/LICENSE)[![Build Status](https://camo.githubusercontent.com/f22d5b27fb9e94d1424b6bc2dd226dcf61eb5dee429e62fb8a49d9816ba1ac60/68747470733a2f2f7472617669732d63692e636f6d2f6e6f727468776f6f64732f656e746974792d70726f78792e737667)](https://travis-ci.com/northwoods/entity-proxy)[![Code Coverage](https://camo.githubusercontent.com/cadad628d2df3a5ecca35d321a0300eeb3e2d4b8622e1efe728b97386c1b9c74/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e6f727468776f6f64732f656e746974792d70726f78792f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/northwoods/entity-proxy/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7a85375cbee4d13ceba5348ab9bc9a6043fcf454b0ab12725849711248be0364/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e6f727468776f6f64732f656e746974792d70726f78792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/northwoods/entity-proxy/?branch=master)

A [reflection](http://php.net/reflection) based proxy for hydrating objects with private properties.

Attempts to be [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/), and [PSR-4](http://www.php-fig.org/psr/psr-4/) compliant.

Install
-------

[](#install)

```
composer require northwoods/entity-proxy

```

Usage
-----

[](#usage)

Proxies are created with the singleton `ProxyFactory`:

```
use Northwoods\EntityProxy\ProxyFactory;
```

Proxies can be created as wrappers around existing objects:

```
$proxy = ProxyFactory::modify($user);

$proxy->set('email', 'user@example.com');
```

Or new instances when hydrating from other data sources:

```
$proxy = ProxyFactory::create(User::class);

$proxy->setArray([
    'id' => 1234,
    'username' => 'jane.doe',
    'email' => null,
]);

/** @var User */
$user = $proxy->reveal();
```

Proxies can also read existing values on the object:

```
$username = $proxy->get('username');
```

Reasoning
---------

[](#reasoning)

In Domain Driven Design it is often recommended that entities use private properties with getters to access state and setters to change state based on business requirements. Since an entity is considered to be a persistent object, its constructor should only be called **once for the lifetime of the entity**. This allows for domain events to be triggered by the constructor to notify the application that, for example, a new user has registered.

With this limitation in mind, the requirements for the hydrator are:

1. It must not call the entity constructor.
2. It must be able to set private/protected properties.
3. It must be as efficient as possible.

The easiest way to achieve these goals is to use reflection, which allows us to [create objects without constuctor](https://php.net/manual/en/reflectionclass.newinstancewithoutconstructor.php), [make properties accessible](https://php.net/manual/en/reflectionproperty.setaccessible.php), and [write property values](https://php.net/manual/en/reflectionproperty.setvalue.php). The reflection of every class should be internally cached for the lifetime of the factory to maximize performance.

If performance is of concern there are [other viable approaches](https://packagist.org/packages/ocramius/generated-hydrator)that are faster but more complicated to setup and use.

License
-------

[](#license)

MIT

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

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

Total

4

Last Release

2803d ago

Major Versions

1.1.0 → 2.0.02018-09-10

PHP version history (2 changes)1.0.0PHP &gt;=7.1

2.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/38203?v=4)[Woody Gilk](/maintainers/shadowhand)[@shadowhand](https://github.com/shadowhand)

---

Top Contributors

[![shadowhand](https://avatars.githubusercontent.com/u/38203?v=4)](https://github.com/shadowhand "shadowhand (11 commits)")

---

Tags

dddentityhydratorphpreflection

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/northwoods-entity-proxy/health.svg)

```
[![Health](https://phpackages.com/badges/northwoods-entity-proxy/health.svg)](https://phpackages.com/packages/northwoods-entity-proxy)
```

###  Alternatives

[mettle/sendportal

SendPortal. Open-source self-hosted email marketing. Manage your own newsletters at a fraction of the cost.

2.1k4.3k](/packages/mettle-sendportal)[crell/envmapper

A simple, fast mapper from environment variables to classed objects.

8713.7k1](/packages/crell-envmapper)[matriphe/larinfo

Display system information (IP address, OS, versions) for Laravel.

4739.9k3](/packages/matriphe-larinfo)[evotodi/seed-bundle

Seeder for symfony 6/7

1365.3k](/packages/evotodi-seed-bundle)[peterbrinck/nova-laravel-news

Adds a card to the Nova dashboard with the latest news from Laravel News

1711.7k](/packages/peterbrinck-nova-laravel-news)

PHPackages © 2026

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