All Projects → joomla-framework → registry

joomla-framework / registry

Licence: GPL-2.0 license
Joomla Framework Registry Package

Programming Languages

PHP
23972 projects - #3 most used programming language
Jsonnet
166 projects

Projects that are alternatives of or similar to registry

astroid-framework
Powerful framework for designers and developers to create responsive, fast & robust Joomla based websites and templates.
Stars: ✭ 26 (+62.5%)
Mutual labels:  joomla, joomla-framework
form
[DEPRECATED] Joomla Framework Form Package
Stars: ✭ 12 (-25%)
Mutual labels:  joomla, joomla-framework
Astroid-Framework
Powerful framework for designers and developers to create responsive, fast & robust Joomla based websites and templates.
Stars: ✭ 99 (+518.75%)
Mutual labels:  joomla, joomla-framework
github-api
Joomla Framework GitHub Package
Stars: ✭ 21 (+31.25%)
Mutual labels:  joomla, joomla-framework
database
Joomla Framework Database Package
Stars: ✭ 25 (+56.25%)
Mutual labels:  joomla, joomla-framework
quitsies
A persisted drop-in replacement for Memcached, respecting the rules of quitsies.
Stars: ✭ 16 (+0%)
Mutual labels:  key-value
qucli
Manage repositories in Quay.io
Stars: ✭ 29 (+81.25%)
Mutual labels:  registry
cantor
Data abstraction, storage, discovery, and serving system
Stars: ✭ 25 (+56.25%)
Mutual labels:  key-value
schema-registry
📙 json & avro http schema registry backed by Kafka
Stars: ✭ 23 (+43.75%)
Mutual labels:  registry
rosedb
🚀 A high performance NoSQL database based on bitcask, supports string, list, hash, set, and sorted set.
Stars: ✭ 2,957 (+18381.25%)
Mutual labels:  key-value
XT-Tailwind-for-Joomla
XT Tailwind for Joomla. My Blog template, based on Tailwind CSS.
Stars: ✭ 15 (-6.25%)
Mutual labels:  joomla
gocache
High performance and lightweight in-memory cache library with LRU and FIFO support as well as memory-usage-based-eviction
Stars: ✭ 15 (-6.25%)
Mutual labels:  key-value
nim-lmdb
Nim LMDB wrapper
Stars: ✭ 31 (+93.75%)
Mutual labels:  key-value
huffleraft
Replicated key-value store driven by the raft consensus protocol 🚵
Stars: ✭ 32 (+100%)
Mutual labels:  key-value
cruzdb
Append-only key-value database on a distributed shared-log
Stars: ✭ 47 (+193.75%)
Mutual labels:  key-value
openshift-disconnected-operators
No description or website provided.
Stars: ✭ 52 (+225%)
Mutual labels:  registry
joomla-twig
Twig 2.0 & Twig extensions integration for Joomla! https://phproberto.github.io/joomla-twig/
Stars: ✭ 25 (+56.25%)
Mutual labels:  joomla
FOF3-Basic
A hello world type example for Akeeba F0F3 as a walkthrough for building a Joomla! component from the ground up.
Stars: ✭ 14 (-12.5%)
Mutual labels:  joomla
Windows10Tools
Tools for Windows 10
Stars: ✭ 45 (+181.25%)
Mutual labels:  registry
Curator
A lightweight key-value file manager written in Swift.
Stars: ✭ 14 (-12.5%)
Mutual labels:  key-value

The Registry Package Build Status

Latest Stable Version Total Downloads Latest Unstable Version License

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

Load config by Registry

use Joomla\Registry\Registry;

$registry = new Registry;

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

$registry->loadString('<root></root>', 'xml');

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

// Load by file
$registry->loadFile($root . '/config/config.json', 'json');

Accessing a Registry by getter & setter

Get value

$registry->get('foo');

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

// OR

$registry->get('foo') ?: 'default';

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

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

$registry = new Registry($json);

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

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

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

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

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

$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

$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 via Composer

Add "joomla/registry": "~2.0" to the require block in your composer.json and then run composer install.

{
	"require": {
		"joomla/registry": "~2.0"
	}
}

Alternatively, you can simply run the following from the command line:

composer require joomla/registry "~2.0"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].