PHPackages                             mr-luke/configuration - 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. mr-luke/configuration

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

mr-luke/configuration
=====================

Dot notation array host configuration package.

1.3.3(3y ago)1476.2k↓64%4MITPHPPHP &gt;=7.1

Since Dec 4Pushed 3y ago1 watchersCompare

[ Source](https://github.com/mr-luke/configuration)[ Packagist](https://packagist.org/packages/mr-luke/configuration)[ RSS](/packages/mr-luke-configuration/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (2)Versions (7)Used By (4)

Configuration Host
==================

[](#configuration-host)

[![Latest Stable Version](https://camo.githubusercontent.com/a3e97e965ca370b2b748df61504680c5ebed5d09b56114f6363088b5f8c72ec6/68747470733a2f2f706f7365722e707567782e6f72672f6d722d6c756b652f636f6e66696775726174696f6e2f762f737461626c65)](https://packagist.org/packages/mr-luke/configuration)[![Total Downloads](https://camo.githubusercontent.com/fe8ad8d536e3b1044e27bb1c472648706f4d67510989da9a1cfbc411a31183a4/68747470733a2f2f706f7365722e707567782e6f72672f6d722d6c756b652f636f6e66696775726174696f6e2f646f776e6c6f616473)](https://packagist.org/packages/mr-luke/configuration)[![License](https://camo.githubusercontent.com/f3b14672631362cb2aaa3d89ff5a9c3cb95ed0f687070feb7c4e2feacf68c6fd/68747470733a2f2f706f7365722e707567782e6f72672f6d722d6c756b652f636f6e66696775726174696f6e2f6c6963656e7365)](https://packagist.org/packages/mr-luke/configuration)

[![Tests Workflow](https://github.com/mr-luke/configuration/actions/workflows/run-testsuit.yaml/badge.svg)](https://github.com/mr-luke/configuration/actions/workflows/run-testsuit.yaml/badge.svg)[![Quality Gate Status](https://camo.githubusercontent.com/0a78a77005cda7a3f94e6187aae4999ff660a42fb56276ee5683c539b90001f9/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6d722d6c756b655f636f6e66696775726174696f6e266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/summary/new_code?id=mr-luke_configuration)[![Security Rating](https://camo.githubusercontent.com/d06e1aa083b37482d1872cb9153669af3e53a44cb59ecfd21b5b7d0b944610aa/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6d722d6c756b655f636f6e66696775726174696f6e266d65747269633d73656375726974795f726174696e67)](https://sonarcloud.io/summary/new_code?id=mr-luke_configuration)[![Reliability Rating](https://camo.githubusercontent.com/d4d950f584f8608c578bb3f4ecb949e15a85d59fdbdbc1a95dd51439a1d04313/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6d722d6c756b655f636f6e66696775726174696f6e266d65747269633d72656c696162696c6974795f726174696e67)](https://sonarcloud.io/summary/new_code?id=mr-luke_configuration)

This package provides array host (wrapper) package that supports dot notation access and schema validation.

- [Getting Started](#getting-started)
- [Installation](#installation)
- [Usage](#usage)
- [Plans](#plans)

Getting Started
---------------

[](#getting-started)

Good software development follows many patterns and architectures. We design things that depends on many other parts. Some of them are well structured Objects but many times we need to have some configurations. Often we use array as our config host but it can produce mass of unexpected side-effects becasue of one reason - array is not an Object so it can't follow any schema. But what if it can...

During my work I developed a simple wrapper tool that helped me with schema sensitive arrays and I decided to make it a package. I hope you enjoy it!

Installation
------------

[](#installation)

To install through composer, simply put the following in your composer.json file and run `composer update`

```
{
    "require": {
        "mr-luke/configuration": "~1.0"
    }
}
```

Or use the following command

```
composer require "mr-luke/configuration"
```

Usage
-----

[](#usage)

Let's move to a `Schema` class. It's a validation tool with one interface method:

```
public function check(array $insert, bool $throw = true): bool
```

- `$insert` - This is your array that is a subject of validation
- `$throw` - This option change behavior of validation

By default `check` method throws an `InvalidArgumentException` when `$insert` doesn't follow schema.

### Step One

[](#step-one)

Create your Schema array:

```
$instruction = [
  'first_key'  => 'required|string',
  'second_key' => 'nullable|integer',
  'third_key'  => 'required|float',
];
```

Available rules:

- `required` - given key must not be empty
- `nullable` - given key can be null
- `boolean` - given key must be boolean type
- `float` - given key must be float type
- `integer` - given key must be integer type
- `string` - given key must be string and can't be other types

### Step Two

[](#step-two)

Create new instance of `Mrluke\Configuration\Schema`:

```
$schema = new Schema(array $instruction);
```

Note! From v1.2.0 you can create `Schema` by static method `createFromFile(string $path, bool $json = false)`.

### Step Three

[](#step-three)

Create new instance of `Mrluke\Configuration\Host` with `Schema` as a dependency and your `$configArray` is automatically validated.

```
$host = new Host($configArray, $schema);
```

If your `$configArray` doesn't follow given `Schema`, you will get `InvalidArgumentException`. You can also use `Host` without any `Schema` due to it's optional parameter of `Mrluke\Configuration\Host`.

### Your configuration is Wrapped!

[](#your-configuration-is-wrapped)

Now you have an access to `Host` methods:

```
/**
 * Return given key from array.
 *
 * @param  string $key
 * @param  mixed  $default
 * @return mixed
 */
public function get(string $key, $default = null)
```

Your `key` can follow **dot notation** to access nested `keys`:

```
$host->get('mysql.database', 'my_db');
```

By default if `key` is not present, `Host` returns `null`. You can also use magic getter to acces config:

```
$host->mysql;
```

You can check if given hey is present:

```
/**
 * Determine if given key is present.
 *
 * @param  string $key
 * @return bool
 */
public function has(string $key): bool
```

Plans
-----

[](#plans)

Feel free to contribute because I am aware that there are some things to improve. For now:

- Nested Schema support
- New validation rules support
- New Schema's file format

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~323 days

Recently: every ~402 days

Total

6

Last Release

1151d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6df8e77a6f4e11408a5658f9127c96ba429354d6ba71a9a5b43966e19455ed17?d=identicon)[mr-luke](/maintainers/mr-luke)

---

Top Contributors

[![mr-luke](https://avatars.githubusercontent.com/u/12121875?v=4)](https://github.com/mr-luke "mr-luke (16 commits)")

---

Tags

arrayconfigurationphp7schema-validationwrapperphpconfigurationarrayhost

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mr-luke-configuration/health.svg)

```
[![Health](https://phpackages.com/badges/mr-luke-configuration/health.svg)](https://phpackages.com/packages/mr-luke-configuration)
```

PHPackages © 2026

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