This package is abandoned and no longer maintained. No replacement package was suggested.

Framework Agnostic Persistent Typed and Group-able Settings with JSON Driver

2.0.0 2016-07-28 12:51 UTC

This package is not auto-updated.

Last update: 2019-11-04 08:48:28 UTC


Framework Agnostic Persistent Typed and Group-able Settings with JSON Driver.

Build Status Total Downloads Latest Stable Version License

Settlement provides a simple solution for persistent settings with support for types and groups.


  • Flexible API for persistent settings
  • Configurable JSON driver
  • Grouped and typed settings
  • Group and type validation
  • Service provider for Laravel 5
  • A phpunit test suite for easy development


Installing Settlement is simple. Just pull the package in through Composer.

    "require": {
        "kenarkose/settlement": "~2.0"


Instantiate a new JSON repository with path and filename and you are good to go.

use Kenarkose\Settlement\Repository\JSONRepository;

$settings = new JSONRepository('path/to', 'settings.json');

Here is a list of methods that are defined by the repository interface.

$settings->set('foo', 'bar');
$settings->set('foo', 42, null, 'number');
$settings->set('foo', 'bar', 'Label', 'text', 'baz_group');

$settings->get('foo'); // 'bar'

// ['value' => 'bar', 'label' =>'Label', 'type' => 'text', 'group' => 'baz_group']

$setting->has('foo'); // true


$setting->getGroup('baz_group'); // Name of the Baz Group

$setting->setGroup('foo_group', 'Name of the Foo Group');

$setting->hasGroup('foo_group'); // true

// ['foo' => ['value' => 'bar', 'label' => 'Label', 'type' => 'string', 'group' => 'baz_group']]



Additionally, you may use other methods that is provided by the JSONRepository.

$setting->path(); // Returns current path
$setting->path('new/path'); // Sets a new path

$setting->filename(); // Returns current filename
$setting->filename('config.json'); // Sets a new filename

$setting->settings(); // Returns all stored settings
    ['foo' => ['value' => 'bar', 'type' => 'string', 'group' => null]
); // Replaces stored settings

$setting->groups(); // Returns all stored groups
    ['dummy' => 'Dummy Group']
); // Replaces stored groups

$setting->stored(); // Returns all stored information
    'settings' => [...],
    'groups' => [...]
]); // Replaces all stored information

$setting->load(); // Loads from current path and filename
$setting->load('new/path', 'config.json'); // Loads from new path and filename

$setting->save(); // Saves to current path and filename
$setting->save('new/path', 'config.json'); // Saves to new path and filename

For more options you may refer to source code and tests as Settlement is well tested and documented.

For Laravel Users

The Settlement Service Provider for Laravel 5 registers the default LaravelJSONRepository, the Facade, and the settings() helper.

Laravel Installation

  1. In order to register Settlement Service Provider add 'Kenarkose\Settlement\Provider\Laravel\SettlementServiceProvider' to the end of providers array in your config/app.php file.

    'providers' => array(
  2. You may access the services provided by Settlement by using the supplied Facade.

    Settings::set('bar', 'baz');

    In order to register the Facade add 'Settings' => 'Kenarkose\Settlement\Provider\Laravel\Settings' to the end of aliases array in your config/app.php file.

    'aliases' => array(
        'App'        => 'Illuminate\Support\Facades\App',
        'Artisan'    => 'Illuminate\Support\Facades\Artisan',
        'Settings' => 'Kenarkose\Settlement\Provider\Laravel\Settings',
  3. A helper function is also provided if the Facade is not preferred.

    settings(); // Returns the repository
    // Getting a value
    settings('foo'); // is the same as settings()->get('foo');
    // Setting a value
    settings('foo', 'bar'); // is the same as settings()->set('foo', 'bar');
    // Other possible derivations of setting
    settings('foo', 'bar', 'string');
    settings('foo', 'bar', 'string', 'group');
  4. Finally, you may customize Settlement's behavior by publishing the configuration file. To do so, use the following command.

    php artisan vendor:publish

    Than, you will find the configuration file on the config/settlement.php path.


Settlement is released under MIT License.