PHPackages                             balinomad/simple-config - 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. balinomad/simple-config

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

balinomad/simple-config
=======================

Simple library to create and modify a configuration structure.

v1.0.0(9mo ago)3201MITPHPPHP ^8.1CI passing

Since Sep 26Pushed 9mo ago1 watchersCompare

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

READMEChangelog (5)Dependencies (4)Versions (8)Used By (0)

Simple config [![Latest Version](https://camo.githubusercontent.com/baeb0c577b33e63622876c4b483fddd99502ecac31b8ca7032a2037c99c144c9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f62616c696e6f6d61642f73696d706c652d636f6e6669673f736f72743d73656d766572266c6162656c3d76657273696f6e)](https://raw.githubusercontent.com/balinomad/simple-config/master/CHANGELOG.md)
====================================================================================================================================================================================================================================================================================================================================================================================================

[](#simple-config-)

[![Unit tests](https://github.com/balinomad/simple-config/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/balinomad/simple-config/actions/workflows/test.yml)[![Code analysis](https://github.com/balinomad/simple-config/actions/workflows/analysis.yml/badge.svg)](https://github.com/balinomad/simple-config/actions/workflows/analysis.yml)[![Coverage Status](https://camo.githubusercontent.com/0bfe342ddcda2182720720c05f423b074f2c9b07a8a0108b3c1b6d4ea6d79dd1/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f62616c696e6f6d61642f73696d706c652d636f6e6669672f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/balinomad/simple-config?branch=master)[![License: MIT](https://camo.githubusercontent.com/d6bc2b26794002c24d023acaab01b6dbb953c57ab9cb80ba5b8aa2f2bd5de99a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c7565)](https://opensource.org/licenses/MIT)

1. What Is It
-------------

[](#1-what-is-it)

**Simple config** is a class to work with configuration settings. It helps you to perform actions like add, remove, check, append, subtract etc. by using dot notation keys.

2. What Is It Not
-----------------

[](#2-what-is-it-not)

This library does not read the filesystem or other environment settings. To use an *.env* file to feed **Simple config**, use it together with [phpdotenv](https://github.com/vlucas/phpdotenv) or other similar library.

3. Installation
---------------

[](#3-installation)

This package can be installed through [Composer](https://getcomposer.org/).

```
composer require balinomad/simple-config
```

4. Usage
--------

[](#4-usage)

The `Config` object is **immutable**. This means methods like `with`, `without`, `append`, and `merge` do not change the original object; they return a new, modified `Config` instance.

```
use BaliNomad\SimpleConfig\Config;

$options = [
    'allowed_pets' => ['dog', 'cat', 'spider'],
    'cat' => [
        'name' => 'Mia',
        'food' => ['tuna', 'chicken', 'lamb'],
    ],
    'dog' => [
        'name' => 'Bless',
        'color' => [
            'body' => 'white',
            'tail' => 'black',
        ]
    ],
    'has_spider' => true
];

$config = new Config($options);

// with(), without(), etc. return a NEW Config instance.
$newConfig = $config
    ->with('has_spider', false)                 // Set a value
    ->without('dog.color.tail')                 // Remove a value
    ->append('cat.food', 'salmon')              // Add an item to an array
    ->subtract('allowed_pets', 'spider');       // Remove an item from an array

// Get values using dot notation
$catFood = $newConfig->get('cat.food');
// Returns: ['tuna', 'chicken', 'lamb', 'salmon']

// Check if a key exists
$hasTailColor = $newConfig->has('dog.color.tail');
// Returns: false

// The original $config object remains unchanged
$originalSpiderSetting = $config->get('has_spider');
// Returns: true

// Get the entire configuration as an array
$arrConfig = $newConfig->toArray();
```

5. API Reference
----------------

[](#5-api-reference)

MethodAttributesReturnsDescription*constructor*`?array $config`, `int $cleaningFlags``self`Creates a new Config instance.`with``$key`, `$value``self`Returns a **new** instance with a value set.`without``$key``self`Returns a **new** instance with a key removed.`get``$key`, `$default``mixed`Retrieves a value using dot notation.`has``$key``bool`Checks if a key exists.`append``$key`, `$value``self`Returns a **new** instance with a value appended to an array.`subtract``$key`, `$value``self`Returns a **new** instance with a value removed from an array.`merge``$config`, `$method``self`Returns a **new** instance merged with another configuration.`split``$key``self`Returns a **new** instance containing only a subset of the config.`toArray`-`array`Returns the entire configuration as an array.`count`-`int`Counts all leaf configuration values. Non-associative arrays are counted as a single leaf.`getIterator`-`Traversable`Gets an iterator for the top-level items.`offsetExists``$offset``bool`Implements `ArrayAccess`. Checks if a key exists (e.g., `isset($config['app.key'])`).`offsetGet``$offset``mixed`Implements `ArrayAccess`. Gets a value (e.g., `$config['app.key']`).**Note**: Modifying a `Config` object via array access (e.g., `$config['key'] = 'value'`) is not permitted and will throw a `LogicException`. Use the `with()` and `without()` methods instead.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance56

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 76.3% of commits — single point of failure

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 ~280 days

Recently: every ~351 days

Total

6

Last Release

291d ago

Major Versions

v0.3.0 → v1.0.02025-07-31

PHP version history (4 changes)v0.1.0PHP ^7.3|^8.0

v0.2.1PHP ^7.4 || ^8.0

v0.3.0PHP ^8.0

v1.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/b636be96ccee755b83b839b769bf6d992b16518fa8e910ce698f705f7a11079e?d=identicon)[balinomad](/maintainers/balinomad)

---

Top Contributors

[![balinomad](https://avatars.githubusercontent.com/u/26588579?v=4)](https://github.com/balinomad "balinomad (45 commits)")[![mallardduck](https://avatars.githubusercontent.com/u/619938?v=4)](https://github.com/mallardduck "mallardduck (14 commits)")

---

Tags

phpconfigurationconfigoptions

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/balinomad-simple-config/health.svg)

```
[![Health](https://phpackages.com/badges/balinomad-simple-config/health.svg)](https://phpackages.com/packages/balinomad-simple-config)
```

###  Alternatives

[symfony/options-resolver

Provides an improved replacement for the array\_replace PHP function

3.2k493.9M1.6k](/packages/symfony-options-resolver)[sandrokeil/interop-config

Provides interfaces and a concrete implementation to create instances depending on configuration via factory classes and ensures a valid config structure. It can also be used to auto discover factories and to create configuration files.

58446.7k34](/packages/sandrokeil-interop-config)[caseyamcl/configula

A simple, but versatile, PHP config loader

42146.6k6](/packages/caseyamcl-configula)

PHPackages © 2026

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