spaaleks / laragistry
Laragistry - a minimal Laravel key/value registry
1.0.0
2021-09-07 13:02 UTC
README
This Package contains a minimal registry logic for your Laravel 7+/8+ application.
The aim was to create a simple key/value provider for configuration purpose. For e.g. multi-domain applications, a scope
can be used to separate entries.
This package does also work with the Laravel MongoDB driver from Jens Segers (jenssegers/laravel-mongodb)
Installation
Install the package via composer.
composer require spaaleks/laragistry
Run the artisan migration command to create the laragistry table.
php artisan migrate
Usage
After installing, you can use the Spaaleks\Laragistry\Laragistry
class or it's alias (\Laragistry
) in your project.
The scope argument is optional for every command.
Method | Examples | Returns | Description |
---|---|---|---|
Create/update entry \Laragistry::set(array $data, string $scope = null) |
\Laragistry::set(['key', 'value']); \Laragistry::set(['key', 'value'], 'default'); |
entry object | This command will create a new entry or update a existing by key and scope. |
Create/update multiple entries \Laragistry::set(array $data, string $scope = null) |
\Laragistry::set([ ['key1', 'value1'], ['key2', 'value2'] ]); |
entry object or collection of entries | The same set command can be used to create/update multiple entries by providing a multidimensional array. |
Get a single entry or multiple entries \Laragistry::get($data, string $scope = null) |
\Laragistry::get('key'); \Laragistry::get(['key1', 'key2']); \Laragistry::get('key_*'); \Laragistry::get(['key1_*', 'key2_*']); |
entry object or collection of entries | Get a single entry or multiple entries by providden key(s). |
Check \Laragistry::check(string $key, string $scope = null) |
\Laragistry::check('key1'); |
boolean | This command checks whether a key exists. |
Get all in scope \Laragistry::getByScope(string $scope) |
\Laragistry::getByScope('my_scope'); |
collection of entries | Return all key's in a scope. |
Remove a single entry or multiple entries \Laragistry::remove($data, string $scope = null) |
\Laragistry::remove('key'); \Laragistry::remove(['key1', 'key2']); |
boolean | Remove a single entry or multiple entries by providden key(s). |