PHPackages                             wubs/json-settings - 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. wubs/json-settings

ActiveLibrary

wubs/json-settings
==================

Package to easily manage a json setting file

025PHP

Since Jun 18Pushed 12y ago1 watchersCompare

[ Source](https://github.com/megawubs/json-settings)[ Packagist](https://packagist.org/packages/wubs/json-settings)[ RSS](/packages/wubs-json-settings/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

json-settings
=============

[](#json-settings)

This package aims to make a json setting file usable and easy maintainable.

The json file is build like this:

```
{
	"foo":{
		"bar":"foo",
		"bars":"foos",
	}
}
```

Where `foo` is a group and `bar` a key value pair.

It is possible to append groups and add new groups.

usage examples
--------------

[](#usage-examples)

### Getting settings

[](#getting-settings)

Getting a setting is straight forward.

```
//gets the value of bar in the foo group
$value = $s->get('foo.bar'); //foo
//gets the value of bars in the foo group
$values = $s->get('foo.bars'); //foos
```

### Filling the settings file

[](#filling-the-settings-file)

This can be done by giving `$settings` as a parameter when creating a new Settings object

`$settings` can either be a json string or an array

```
$settings = array('foo'=>array('bar'=>'foo', 'bars'=>'foos'));
$s = new Settings($settings);
print_r($s->getSettingsAsArray());
/**
 * Array
 *(
 *   [foo] => Array
 *       (
 *           [bar] => foo
 *           [bars] => foos
 *       )
 *
 *)
 *
 */
```

Or by calling the fill method

```
$settings = array('foo'=>array('bar'=>'foo', 'bars'=>'foos'));
$s = new Settings();
$s->fill($settings);
```

### Appending groups

[](#appending-groups)

To add new settings to a existing group goes as follows

```
//we assume the settings file is already filled
$s->appendGroup('foo','cackes');
```

The group foo has now a new key value pair with the key `'cackes'`. The value defaults to `''`If you want to add a default value use a third parameter like this

```
$s->appendGroup('foo','cackes','cheesecake');
```

### Add a new group

[](#add-a-new-group)

Adding a new group to the settings file, and give it some default settings.

```
$s->addGroup('files')->appendGroup('files', 'logfile', '/location/to/file.log');
```

### Todo:

[](#todo)

- Make it a separate package
- Add functionality to extend the json settings
- Make the settings file dynamic
- Allow greater settings depth
- Allow arrays when adding a new group

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/022fedda76a958ff5a3501ad805aa26d342f8a984263aa1faea2045399055915?d=identicon)[megawubs](/maintainers/megawubs)

### Embed Badge

![Health badge](/badges/wubs-json-settings/health.svg)

```
[![Health](https://phpackages.com/badges/wubs-json-settings/health.svg)](https://phpackages.com/packages/wubs-json-settings)
```

PHPackages © 2026

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