PHPackages                             innmind/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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. innmind/config

AbandonedArchivedLibrary[Validation &amp; Sanitization](/categories/validation)

innmind/config
==============

Config schema validator

1.1.0(8y ago)016MITPHPPHP ~7.2

Since Apr 1Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Innmind/Config)[ Packagist](https://packagist.org/packages/innmind/config)[ Docs](http://github.com/Innmind/Config)[ RSS](/packages/innmind-config/feed)WikiDiscussions develop Synced 3d ago

READMEChangelogDependencies (4)Versions (4)Used By (0)

Config
======

[](#config)

`master``develop`[![Scrutinizer Code Quality](https://camo.githubusercontent.com/26eff4a5e2bf1102a6a884186b8f46b2c429ae807a02dbc4198c2b4bc391495c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f496e6e6d696e642f436f6e6669672f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Innmind/Config/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7730027b8a19504ff146ecde554d6be1347fe615410e0e150deb794c51d7f91a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f496e6e6d696e642f436f6e6669672f6261646765732f7175616c6974792d73636f72652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/Innmind/Config/?branch=develop)[![Code Coverage](https://camo.githubusercontent.com/680b29cb906f17bebbf2588e9d0a0a9d89e2ed1816d29fe55225fdc3aeb96262/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f496e6e6d696e642f436f6e6669672f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Innmind/Config/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/76ed361f639e571154b58a82ad1dd85b945424fccde239f0202aa0e38674306f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f496e6e6d696e642f436f6e6669672f6261646765732f636f7665726167652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/Innmind/Config/?branch=develop)[![Build Status](https://camo.githubusercontent.com/ad43d390f2852c80867b31311f6cb434445ef813740cde18490a5cced8b41c0e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f496e6e6d696e642f436f6e6669672f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Innmind/Config/build-status/master)[![Build Status](https://camo.githubusercontent.com/e00e6d8189f0eee2c73c469494bb64c8cae49566f469f677785096d27195aff7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f496e6e6d696e642f436f6e6669672f6261646765732f6275696c642e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/Innmind/Config/build-status/develop)Library to enforce a configuration schema with an emphasis on schema visualization.

It's born after a constant struggle to build prototype definitions with [`symfony/config`](https://symfony.com/doc/current/components/config.html) as well as the fact prototypes can't be mixed with property definitions.

**Note**: a prototype is a definition allowing to repeat the sub-schema in the array, for example `prototype: bool` allows you to have a configuration like `[1 => true, 2 => false /* etc... */]`.

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

[](#installation)

```
composer require innmind/config
```

Usage
-----

[](#usage)

To better visualize the config schema you should define it via yaml or json (or any other minimalist format). Here's an example showing the possibilities of this library:

```
# schema.yml
prototype:
    type: string
    alias: '?string'
    repository: '?string'
    factory: '?string'
    labels: set
    identity:
        property: string
        type: string
    properties:
        prototype:
            type: string
            prototype: mixed
```

```
use Innmind\Config\Config;
use Symfony\Component\Yaml\Yaml;

$config = (new Config)->build(Yaml::parseFile('schema.yml'));
$data = $config->process($data);
```

When you call `process` it will validate the `$data` but also transform the data in case of `set`, `stream` and `sequence` types by returning instances of `Innmind\Immutable\Set`, `Innmind\Immutable\Stream` and `Innmind\Immutable\Sequence`, the `$data` returned is also a `Innmind\Immutable\Map` instead of a simple array in order to ease the manipulation of the config data.

The full list of keys formats you can use:

- `prototype` will instruct to have an int as a key
- `prototype+` will instruct to have an int as a key and to have at least one key
- `prototype` will instruct to have an string as a key
- `prototype+` will instruct to have an string as a key and to have at least one key
- `prototype` will instruct to have an scalar as a key
- `prototype+` will instruct to have an scalar as a key and to have at least one key
- any other string will be considered as a key name

The full list of values formats you can use:

- any value having a `is_{type}` function, this includes `int`, `float`, `bool`, `string`, `scalar`, `array`, `object` and `resource`, can be declared optional by prefixing with a `?`
- `set` where `type` is any value accepted by `Innmind\Immutable\Set`
- `set+` where `type` is any value accepted by `Innmind\Immutable\Set` and must at least have one value
- `stream` where `type` is any value accepted by `Innmind\Immutable\Stream`
- `stream+` where `type` is any value accepted by `Innmind\Immutable\Stream` and must at least have one value
- `sequence`
- `sequence+` must have at least one value
- `enum({typeA|typeB})` possible values separated by a `|`
- `?enum({typeA|typeB})` possible values separated by a `|` but the value is optional

Extend behaviour
----------------

[](#extend-behaviour)

The formatsshowed are the one by defaults but you can easily yours, for that you need to implements either [`Structure`](src/Structure.php) or [`Property`](src/Property.php) then to use it:

```
$config = new Config(
    new Structures(
        ...Structures::defaults()->add(MyStructure::class)
    ),
    new Properties(
        ...Properties::defaults()->add(MyProperty::class)
    )
);
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

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

Total

2

Last Release

2965d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/851425?v=4)[Baptiste Langlade](/maintainers/Baptouuuu)[@Baptouuuu](https://github.com/Baptouuuu)

---

Top Contributors

[![Baptouuuu](https://avatars.githubusercontent.com/u/851425?v=4)](https://github.com/Baptouuuu "Baptouuuu (16 commits)")

---

Tags

validatorconfig

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[seld/jsonlint

JSON Linter

1.3k217.8M205](/packages/seld-jsonlint)[composer/spdx-licenses

SPDX licenses list and validation library.

1.4k184.2M25](/packages/composer-spdx-licenses)[nette/schema

📐 Nette Schema: validating data structures against a given Schema.

1.0k336.4M125](/packages/nette-schema)[opis/json-schema

Json Schema Validator for PHP

64236.9M186](/packages/opis-json-schema)[intervention/validation

Additional validation rules for the Laravel framework

6826.7M8](/packages/intervention-validation)

PHPackages © 2026

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