PHPackages                             shov/laravel-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. shov/laravel-registry

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

shov/laravel-registry
=====================

The implementation of Registry pattern for Laravel

v0.2(8y ago)028BSD-2-ClausePHPPHP &gt;=7.0

Since Feb 20Pushed 8y ago1 watchersCompare

[ Source](https://github.com/shov/laravel-registry)[ Packagist](https://packagist.org/packages/shov/laravel-registry)[ RSS](/packages/shov-laravel-registry/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (3)Versions (5)Used By (0)

[![](https://camo.githubusercontent.com/4e46520f4f4c519a6a301133db1fcea05507121bc48adf51f8e4e9dd26356e32/68747470733a2f2f636f6d65742e62792f696d672f6c61726176656c2d72656769737472792e7376673f3232)](https://camo.githubusercontent.com/4e46520f4f4c519a6a301133db1fcea05507121bc48adf51f8e4e9dd26356e32/68747470733a2f2f636f6d65742e62792f696d672f6c61726176656c2d72656769737472792e7376673f3232)

[![](https://camo.githubusercontent.com/2d5339ab3e764a220f5d6f516b0802365e5eaf236a87f531cb35ea0816bf10a2/68747470733a2f2f7472617669732d63692e6f72672f73686f762f6c61726176656c2d72656769737472792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/shov/laravel-registry)[![](https://camo.githubusercontent.com/7ef7e1d08669683948debd2e9865773c9f851a6a535ebaf5de47f97f4fa69ab7/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f73686f762f6c61726176656c2d72656769737472792e737667)](https://camo.githubusercontent.com/7ef7e1d08669683948debd2e9865773c9f851a6a535ebaf5de47f97f4fa69ab7/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f73686f762f6c61726176656c2d72656769737472792e737667)[![](https://camo.githubusercontent.com/5f032fcad5d99a611b3cc6afd7a2b209be18061228f13b19227b6ce632cc51fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73686f762f6c61726176656c2d72656769737472792e737667)](https://camo.githubusercontent.com/5f032fcad5d99a611b3cc6afd7a2b209be18061228f13b19227b6ce632cc51fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73686f762f6c61726176656c2d72656769737472792e737667)[![](https://camo.githubusercontent.com/f955836b5a5ef41bb3ffd7c6e4c6673b9732d6cc231bc04179a656d4f228548a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f73686f762f6c61726176656c2d72656769737472792e737667)](https://camo.githubusercontent.com/f955836b5a5ef41bb3ffd7c6e4c6673b9732d6cc231bc04179a656d4f228548a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f73686f762f6c61726176656c2d72656769737472792e737667)

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

[](#installation)

Run in root of project `composer require shov/laravel-registry`

Register service provider in your `config/app.php`

```
    providers' => [
        ...

        /*
         * Package Service Providers...
         */
        Shov\Registry\RegistryServiceProvider::class,

        ...
    ]

```

Usage
-----

[](#usage)

You allow to use DI or Facade to get registry instance

```
$this->registry
    ->set('foo', 'x')
    ->values(['bar' => 'y']);

$xy = $this->registry->get('foo')
      . $this->registry->get('bar');

assert('xy' === $xy);

$empty = $this->registry
            ->set('some', 'value')
            ->set('foo', 'bar')
            ->immutable('answer', 42)
            ->flush(true)
            ->all();

assert(empty($empty));
```

### Methods

[](#methods)

MethodDescriptionhas(string $key): boolChecks does the Registry has value for given key (including the immutable).get(string $key, $default = null): mixedTries to get value by given key, in a case there is no value for given key will be returned default value.all(array $defaults = \[\]): arrayFetches all stored values (as key-value pairs array). Returns default array if no values. Includes immutable.set(string $key, $value): staticTries to set/rewrite value by key. Be careful if key refers to immutable you will got an exception.values(array $pairs): staticTries to set/rewrite values by key and do it with key-value pairs array. Be careful if one given of keys refers to immutable you will got an exception.immutable(string $key, $value): staticTries to set immutable value for given key. Be careful if key already refers to immutable you will got an exception. Important thing is this condition: if you make immutable with key the same of existing the regular one, you can't to get the regular value because getting immutable values has the priority, but you still possible to reset regular value with this key using set()forget(string $key): staticRemoves regular key-value pair. Be careful if key refers to immutable you will got an exception.flush(bool $force): staticRemoves all regular key-value pairs. If you pass the true for $force all immutable pairs will removed as well.getImmutableKeys(): arrayReturns one-dimension array of keys of immutable pairs stored in Registry.stopPersist(): staticAfter calling this function all changes will be holding just in memory and will be lost when script was terminated.Overview
--------

[](#overview)

The goal of this project is implement this interface:

```
,---------------------------------------------.
|RegistryInterface                            |
|---------------------------------------------|
|---------------------------------------------|
|+has(string $key): bool                      |
|                                             |
|+get(string $key, $default = null): mixed    |
|+all(array $defaults = []): array            |
|                                             |
|+set(string $key, $value): static            |
|+values(array $pairs): static                |
|                                             |
|+immutable(string $key, $value): static      |
|                                             |
|+forget(string $key): static                 |
|+flush(bool force): static                   |
|                                             |
|+getImmutableKeys(): array                   |
|                                             |                                             |
|+stopPersist(): static                       |
`---------------------------------------------'

```

And provide it via IoC container two ways:

1. DI via `public function __constructor(Registry $registry)`
2. As the Facade `Registry::has('key');`

The save and loading data are making with the members given by constructor according to interfaces SaverInterface, LoaderInterface. I would like to provide several implementation looks like DbSaver, StorageSaver, FakeSaver (which do nothing when saving). So let's going to interfaces:

```
,---------------------.
|SaverInterface       |
|---------------------|
|---------------------|
|+save(array $pairs)  |
`---------------------'

,---------------------.
|LoaderInterface      |
|---------------------|
|---------------------|
|+load(): array       |
`---------------------'

```

Then it should be great to publish the config which set the implementations we will use when run

For a while I'll put the tasks to the Issues tab

#### Locking

[](#locking)

Well now I explain my point about locking.

```
,---------------------------------------------.
|RegistryInterface                            |
|---------------------------------------------|
|---------------------------------------------|
|                                             |
|+lock(string ...$keys): static               |
|+lockAll(): static                           |
|+getLockedKeys(): array                      |
|                                             |
`---------------------------------------------'

```

First, the locking isn't persisting, that means the pairs which you have to lock, should be locked every time script run in code. Before you'll lock it the values can be changed.

Consequently as well as you desired make the pair locked you've got no method to unlock while script going on.

However the important thing is keeping in you mind the regular Registry has a global storage and any other process can change the value of the locked pair.

Global instances are dangerous. Actually I have to make think about it bit more. May be there is the reason to persist locked pairs or otherwise don't persist them never

The case I put locking to another instance:

```
,---------------------------------.
|LockerInterface                  |
|---------------------------------|
|---------------------------------|
|+lock(string ...$keys): array    |
|+unlock(string ...$keys): static |
|                                 |
|+isLocked(string $key): bool     |
|+getLockedKeys(): array          |
`---------------------------------'

```

Just now I put locking to the backlog for a while.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

Total

3

Last Release

2973d ago

PHP version history (2 changes)v0.1PHP &gt;=7.1

v0.2PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/57079b10395ab18222d93ee935e03dba10a3313edd8a8c2f65d01023ce35438a?d=identicon)[shov](/maintainers/shov)

---

Top Contributors

[![shov](https://avatars.githubusercontent.com/u/1494325?v=4)](https://github.com/shov "shov (7 commits)")

---

Tags

phplaravelconfigurationSettingsregistrylaravel-registry

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/shov-laravel-registry/health.svg)

```
[![Health](https://phpackages.com/badges/shov-laravel-registry/health.svg)](https://phpackages.com/packages/shov-laravel-registry)
```

###  Alternatives

[monicahq/laravel-cloudflare

Add Cloudflare ip addresses to trusted proxies for Laravel.

3372.7M4](/packages/monicahq-laravel-cloudflare)[kra8/laravel-snowflake

Snowflake for Laravel and Lumen.

188402.3k6](/packages/kra8-laravel-snowflake)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)[torann/registry

Laravel registry manager for application configurations

222.0k](/packages/torann-registry)[illuminatech/array-factory

Allows DI aware object creation from array definition

2159.6k6](/packages/illuminatech-array-factory)

PHPackages © 2026

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