PHPackages                             msgframework/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. msgframework/registry

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

msgframework/registry
=====================

The Registry package provides an indexed key-value data store and an API for importing/exporting this data to several formats.

v1.0.2(4y ago)0343MITPHPPHP &gt;=7.4

Since Jan 7Pushed 4y ago1 watchersCompare

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

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

The Registry library
====================

[](#the-registry-library)

[![Latest Stable Version](https://camo.githubusercontent.com/c5e2bcf32d2b60018e729074346e2550b896685bcd1333578204a532550de924/687474703a2f2f706f7365722e707567782e6f72672f6d73676672616d65776f726b2f72656769737472792f76)](https://packagist.org/packages/msgframework/registry)[![Total Downloads](https://camo.githubusercontent.com/047a6a0567c985d578f6d7226e8b4332650d3da355fd7fbd39ef820c3d4c04f7/687474703a2f2f706f7365722e707567782e6f72672f6d73676672616d65776f726b2f72656769737472792f646f776e6c6f616473)](https://packagist.org/packages/msgframework/registry)[![Latest Unstable Version](https://camo.githubusercontent.com/0cbaa223239b1fcdf2e8d2f57142e01ecc3feb6eb4bc0db2eb9ddcfe51f2abe7/687474703a2f2f706f7365722e707567782e6f72672f6d73676672616d65776f726b2f72656769737472792f762f756e737461626c65)](https://packagist.org/packages/msgframework/registry)[![License](https://camo.githubusercontent.com/0d1f921e96af96fd20047f769e9d2295976536666ec0a448c417f0b55d39910b/687474703a2f2f706f7365722e707567782e6f72672f6d73676672616d65776f726b2f72656769737472792f6c6963656e7365)](https://packagist.org/packages/msgframework/registry)[![PHP Version Require](https://camo.githubusercontent.com/8af849a3d694ac6d8f61142653c551ff2468dd6861a009e1e884ab4cc2329410/687474703a2f2f706f7365722e707567782e6f72672f6d73676672616d65776f726b2f72656769737472792f726571756972652f706870)](https://packagist.org/packages/msgframework/registry)

About
-----

[](#about)

The Registry package provides an indexed key-value data store and an API for importing/exporting this data to several formats.

Load Registry
-------------

[](#load-registry)

```
use Msgframework\Lib\Registry\Registry;

$registry = new Registry;

// Load by json string
$registry->loadString('{"foo" : "bar"}');

// Load by object or array
$registry->loadObject($object);
$registry->loadArray($array);
```

Accessing a Registry by getter &amp; setter
-------------------------------------------

[](#accessing-a-registry-by-getter--setter)

### Get value

[](#get-value)

```
$registry->get('foo');

// Get a non-exists value and return default
$registry->get('foo', 'default');
```

### Set value

[](#set-value)

```
// Set value
$registry->set('bar', $value);

// Sets a default value if not already assigned.
$registry->def('bar', $default);
```

### Accessing children value by path

[](#accessing-children-value-by-path)

```
$json = '{
	"parent" : {
		"child" : "Foo"
	}
}';

$registry = new Registry($json);

$registry->get('parent.child'); // return 'Foo'

$registry->set('parent.child', "Goo");

$registry->get('parent.child'); // return 'Goo'
```

Removing values from Registry
-----------------------------

[](#removing-values-from-registry)

```
// Set value
$registry->set('bar', $value);

// Remove the key
$registry->remove('bar');

// Works for nested keys too
$registry->set('nested.bar', $value);
$registry->remove('nested.bar');
```

Accessing a Registry as an Array
--------------------------------

[](#accessing-a-registry-as-an-array)

The `Registry` class implements `ArrayAccess` so the properties of the registry can be accessed as an array. Consider the following examples:

```
// Set a value in the registry.
$registry['foo'] = 'bar';

// Get a value from the registry;
$value = $registry['foo'];

// Check if a key in the registry is set.
if (isset($registry['foo']))
{
	echo 'Say bar.';
}
```

Merge Registry
--------------

[](#merge-registry)

#### Using load\* methods to merge two config files.

[](#using-load-methods-to-merge-two-config-files)

```
$json1 = '{
    "field" : {
        "keyA" : "valueA",
        "keyB" : "valueB"
    }
}';

$json2 = '{
    "field" : {
        "keyB" : "a new valueB"
    }
}';

$registry->loadString($json1);
$registry->loadString($json2);
```

Output

```
Array(
    field => Array(
        keyA => valueA
        keyB => a new valueB
    )
)

```

#### Merge another Registry

[](#merge-another-registry)

```
$object1 = '{
	"foo" : "foo value",
	"bar" : {
		"bar1" : "bar value 1",
		"bar2" : "bar value 2"
	}
}';

$object2 = '{
	"foo" : "foo value",
	"bar" : {
		"bar2" : "new bar value 2"
	}
}';

$registry1 = new Registry(json_decode($object1));
$registry2 = new Registry(json_decode($object2));

$registry1->merge($registry2);
```

If you just want to merge first level, do not hope recursive:

```
$registry1->merge($registry2, false); // Set param 2 to false that Registry will only merge first level
```

Dump to one dimension
---------------------

[](#dump-to-one-dimension)

```
$array = array(
    'flower' => array(
        'sunflower' => 'light',
        'sakura' => 'samurai'
    )
);

$registry = new Registry($array);

// Make data to one dimension

$flatted = $registry->flatten();

print_r($flatted);
```

The result:

```
Array
(
    [flower.sunflower] => light
    [flower.sakura] => samurai
)

```

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

[](#installation)

You can install this package easily with [Composer](https://getcomposer.org/).

Just require the package with the following command:

```
$ composer require msgframework/registry

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

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

3

Last Release

1589d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6879a1f83db6685dc9507b7ad0660480e48e173c053147f3202bdb8d2e4f3bfb?d=identicon)[MSGroupFM](/maintainers/MSGroupFM)

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[smile/module-multi-coupon

Extension of Magento2 Sales Rule to allow multiple coupon usage.

102.9k](/packages/smile-module-multi-coupon)

PHPackages © 2026

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