PHPackages                             modestox/config-processor - 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. modestox/config-processor

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

modestox/config-processor
=========================

Configuration schema validation and processing library for PHP

v1.0.0(yesterday)02↑2900%MITPHPPHP &gt;=8.3CI passing

Since Jun 8Pushed yesterdayCompare

[ Source](https://github.com/Modestox/config-processor)[ Packagist](https://packagist.org/packages/modestox/config-processor)[ Docs](https://github.com/Modestox/config-processor)[ RSS](/packages/modestox-config-processor/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Configuration Processor Component
=================================

[](#configuration-processor-component)

[![Tests](https://github.com/Modestox/config-processor/actions/workflows/phpunit.yml/badge.svg)](https://github.com/Modestox/config-processor/actions/workflows/phpunit.yml/badge.svg)

A standalone PHP component designed for multi-level validation, sanitization, normalization, and sorting of hierarchical system configurations (e.g., application module settings, payment gateways, theme configurations, or plugins).

The architecture is built on a declarative principle of multi-level data grouping: `Tabs -> Sections -> Groups -> Fields`.

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

[](#installation)

```
composer require modestox/config-processor
```

---

Features
--------

[](#features)

- **PHP 8.3+** — Implemented strictly according to the modern language standards.
- **Strict typing** — Native type safety enforced across all validators and configuration nodes.
- **Deep validation** — Comprehensive evaluation of structural constraints, value boundaries, and formats.
- **Recursive normalization** — Automated sanitization and fallback backfilling at every level of the tree.
- **Automatic sorting** — Automatically sorts configuration nodes by `sort_order`.
- **Dependency-aware fields** — Supports conditional visibility constraints between fields inside the same group.
- **Dynamic field registry** — Allows runtime registration or overriding of custom field type strategies.
- **Non-destructive processing** — The input configuration array is never modified or passed by reference.
- **DI-container friendly** — Built with low-coupling architecture ready for dependency injection environments.

---

Why?
----

[](#why)

Most configuration systems mix validation, storage and, UI rendering into a single layer.

Configuration Processor focuses exclusively on configuration structure validation, normalization and consistency, allowing adapters and applications to handle rendering and persistence independently.

---

Supported Schemas
-----------------

[](#supported-schemas)

The processor supports multiple configuration layouts depending on the application requirements.

### System Configuration

[](#system-configuration)

Full hierarchical configuration structure:

```
Tabs
└── Sections
    └── Groups
        └── Fields

```

Designed for large applications, CMS platforms, administration panels, and modular systems.

### Grouped Configuration

[](#grouped-configuration)

Lightweight standalone configuration structure:

```
Groups
└── Fields

```

Designed for isolated plugins, widgets, reusable packages, and small modules that do not require tabs or sections.

---

### Configuration Tree Example

[](#configuration-tree-example)

Example of a typical hierarchical configuration structure:

```
Tabs
└── General (Tab)
    └── API Integration (Section)
        ├── Authentication (Group)
        │   ├── enable_api (Field)
        │   └── api_secret (Field)
        │
        └── Security (Group)

```

Quick Start
-----------

[](#quick-start)

### 1. Installation

[](#1-installation)

```
composer require modestox/config-processor
```

### 2. Raw Configuration Example

[](#2-raw-configuration-example)

The component accepts a raw multi-dimensional array compiled from module configuration files. Note the redundant whitespaces in string values and the unsorted `sort_order` properties:

```
$rawInput = [
    'tabs' => [
        'payment_tab' => [
            'label'      => 'Sales & Payments',
            'sort_order' => 20,
        ],
        'main_tab' => [
            'label'      => '  General Settings  ', // Contains surrounding whitespaces
            'sort_order' => 10, // Should be sorted first
        ]
    ],
    'sections' => [
        'api_integration' => [
            'tab'        => 'main_tab',
            'label'      => 'API Core Integration',
            'sort_order' => 5,
            'groups'     => [
                'auth_group' => [
                    'label'      => 'Authentication Keys',
                    'fields'     => [
                        'enable_api' => [
                            'type' => 'yes_no', // Automatically generates Yes/No options
                        ],
                        'api_secret' => [
                            'type'       => 'password',
                            'default'    => '   secret-token-key   ', // Surrounding whitespaces will be trimmed
                            'depends'    => [
                                'enable_api' => 1 // Only displayed if API is enabled
                            ]
                        ]
                    ]
                ]
            ]
        ]
    ]
];
```

### 3. Processing Configuration

[](#3-processing-configuration)

Pass the input data array and the validation schema instance to the orchestrator:

```
use Modestox\ConfigProcessor\Processor;
use Modestox\ConfigProcessor\Schema\SystemConfig;

$processor = new Processor();
$schema = new SystemConfig();

// OR for isolated plugin structures:
// $schema = new \Modestox\ConfigProcessor\Schema\GroupedConfig();

/** @var array $cleanConfig */
$cleanConfig = $processor->process($rawInput, $schema);
```

### 4. Output of the `process()` Method

[](#4-output-of-the-process-method)

The method returns a **sanitized associative array (`array`)**, where string parameters are normalized, missing properties are populated with system defaults, and elements across all levels are strictly sorted by their `sort_order` values:

```
[
    'tabs' => [
        'main_tab' => [
            'label'      => 'General Settings', // Trimmed and sorted to the first position
            'sort_order' => 10,
            'class'      => '',
            'icon'       => ''
        ],
        'payment_tab' => [
            'label'      => 'Sales & Payments',
            'sort_order' => 20,
            'class'      => '',
            'icon'       => ''
        ]
    ],
    'sections' => [
        'api_integration' => [
            'tab'        => 'main_tab',
            'label'      => 'API Core Integration',
            'sort_order' => 5,
            'class'      => '',
            'icon'       => '',
            'groups'     => [
                'auth_group' => [
                    'label'      => 'Authentication Keys',
                    'sort_order' => 0,
                    'fields'     => [
                        'enable_api' => [
                            'type'       => 'yes_no',
                            'label'      => 'enable_api',
                            'sort_order' => 0,
                            'options'    => [0 => 'No', 1 => 'Yes'], // Generated automatically
                            'default'    => 0,
                            'comment'    => '',
                            'class'      => '',
                            'validation' => [],
                            'required'   => false,
                            'depends'    => null
                        ],
                        'api_secret' => [
                            'type'       => 'password',
                            'label'      => 'api_secret',
                            'sort_order' => 0,
                            'default'    => 'secret-token-key', // Trimmed
                            'comment'    => '',
                            'class'      => '',
                            'validation' => [],
                            'required'   => false,
                            'depends'    => ['enable_api' => 1]
                        ]
                    ]
                ]
            ]
        ]
    ]
]
```

---

Validation Errors
-----------------

[](#validation-errors)

When an invalid structure is detected or field type rules are violated, the processor throws a domain-specific `InvalidConfigException`.

**Example of an invalid field configuration:**

```
'cache_timeout' => [
    'type' => 'number',
    'min'  => 100,
    'max'  => 10, // Error: max is less than min
]
```

**Execution Result:**

```
Modestox\ConfigProcessor\Exception\InvalidConfigException:
Field 'max' cannot be less than 'min' for number field 'cache_timeout'.

```

---

Typical Use Cases
-----------------

[](#typical-use-cases)

The component is framework-agnostic and can serve as the configuration foundation for:

- CMS settings systems
- WordPress plugins and themes
- Laravel administration panels
- Modular applications
- Payment gateway configuration
- Feature flag management
- Internal developer tools
- Dynamic settings generators

---

Supported Field Types Summary
-----------------------------

[](#supported-field-types-summary)

The component natively supports a wide range of standard data types and UI hints:

Field Type (`type`)Behavior &amp; Fallbacks**`text`** / **`textarea`**Standard text data. All values are automatically sanitized using `trim()`.**`password`**Masked input field for sensitive credentials. Values are automatically trimmed.**`boolean`**Enforces strict boolean (`true`/`false`) conversion and fallback values.**`yes_no`**Fast binary dropdown. Automatically injects strict options: `[0 => 'No', 1 => 'Yes']`.**`number`**Enforces strict numeric types (int/float) and logical validation boundaries (`max >= min`).**`datetime`**Strictly validates temporal values against ISO standards (`date`, `time`, or `datetime`).**`dynamic_rows`**Two-dimensional table matrix. Automatically normalizes and backfills nested cell structures.**`file`** / **`image`**Declarative mapping for paths and extensions handled by the application runtime.**`select`** / **`radio`**Single choice options picker. Strictly validates default keys against predefined scope.**`multiselect`** / **`checkbox`**Multiple choice options picker. Enforces default data to be an array of valid keys.**`infoblock`**Non-data text placeholder. Defines how the content should be interpreted by the consuming application.> **Full Property Documentation:** A comprehensive breakdown of each field type, its constraints, inheritance, and validation rules can be found in the separate reference file: [Detailed Field Specifications](fields.md).

---

Architecture Philosophy
-----------------------

[](#architecture-philosophy)

Configuration Processor intentionally focuses only on:

- Validation
- Normalization
- Sanitization
- Structural consistency

The component does not render user interfaces and does not persist user data.

UI rendering, storage layers, and framework integrations should be implemented by adapters built on top of the normalized configuration output.

This separation keeps the core library framework-agnostic, portable, predictable, and easy to integrate into different ecosystems.

---

Component Extension (Registry)
------------------------------

[](#component-extension-registry)

The component supports runtime registration of new field types without altering the core codebase, allowing it to seamlessly integrate with your application's DI containers:

```
use Modestox\ConfigProcessor\Validator\SystemConfig\Fields;

$fieldsValidator = new Fields();
// Register a custom validation strategy for a new 'colorpicker' type
$fieldsValidator->registerType('colorpicker', new MyCustomColorPickerValidator());
```

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance100

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/90475335?v=4)[Sergey Kuzmitsky](/maintainers/Modestox)[@Modestox](https://github.com/Modestox)

---

Top Contributors

[![Modestox](https://avatars.githubusercontent.com/u/90475335?v=4)](https://github.com/Modestox "Modestox (18 commits)")

---

Tags

phpschemavalidatorconfigurationSettingsconfig

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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