PHPackages                             phpnomad/registry - 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. [Framework](/categories/framework)
4. /
5. phpnomad/registry

ActiveLibrary[Framework](/categories/framework)

phpnomad/registry
=================

1.0.2(3w ago)04.5k↓25.7%[3 PRs](https://github.com/phpnomad/registry/pulls)2MITPHPCI passing

Since Apr 26Pushed 2w ago1 watchersCompare

[ Source](https://github.com/phpnomad/registry)[ Packagist](https://packagist.org/packages/phpnomad/registry)[ Docs](https://github.com/phoenix/core)[ RSS](/packages/phpnomad-registry/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (2)Dependencies (6)Versions (13)Used By (2)

phpnomad/registry
=================

[](#phpnomadregistry)

[![Latest Version](https://camo.githubusercontent.com/aa67db915ae32bdd9fe8814a4c1ce149e8cf0bad6cedadf4daee90d78918a433/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068706e6f6d61642f72656769737472792e737667)](https://packagist.org/packages/phpnomad/registry)[![Total Downloads](https://camo.githubusercontent.com/a1a7619c144b6dee1cd7dd15370ee642700042e198d466ce9da2a13379daeb30/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068706e6f6d61642f72656769737472792e737667)](https://packagist.org/packages/phpnomad/registry)[![PHP Version](https://camo.githubusercontent.com/5598b57a79892a1be4cdafe7ade56e1e646965dd0fd9f0f1ce70260ab7e35aa9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7068706e6f6d61642f72656769737472792e737667)](https://packagist.org/packages/phpnomad/registry)[![License](https://camo.githubusercontent.com/8066bdebc62ba4c8212a43adc1f3ed84fb165c8997bdd972787a60f7da7429f9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7068706e6f6d61642f72656769737472792e737667)](https://packagist.org/packages/phpnomad/registry)

`phpnomad/registry` gives you a small kit of interfaces and traits for building named object registries. You define a class, implement the contracts you need, drop in the matching traits, and you have a working store that holds callables and resolves them to objects on first read. It is the shape PHPNomad applications use whenever they need a keyed collection of lazily-built services, handlers, or definitions.

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

[](#installation)

```
composer require phpnomad/registry
```

Overview
--------

[](#overview)

- `CanSet`, `CanGet`, and `CanDelete` interfaces define the standard registry contracts
- `WithSet`, `WithGet`, and `WithDelete` traits supply the default implementations
- Registered values are callables that resolve to objects on first `get()` and cache after
- `getAll()` and `getKeys()` let you walk everything in the registry without separate bookkeeping
- All three traits share the same protected `$registry` array, so you can mix and match the pieces you need

Usage
-----

[](#usage)

Compose a registry by implementing the interfaces you want and using the matching traits. The class body stays empty in most cases, and the lazy resolution handled by `WithGet` keeps object construction off the hot path.

```
