Download the PHP package comphp/config without Composer
On this page you can find all versions of the php package comphp/config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download comphp/config
More information about comphp/config
Files in comphp/config
Package config
Short Description Library designed to simplify the management of configuration files in PHP applications. It leverages the power of dynamic driver loading and custom behaviors to provide a highly adaptable solution for application configuration.
License MIT
Informations about the package config
comphp/config
Overview
The comphp/config
library is designed to simplify the management of configuration files in PHP applications. It leverages dynamic driver loading and custom behaviors to provide a highly adaptable solution for application configuration.
Features
- Supports Multiple Formats: JSON and PHP configurations out of the box.
- Modular & Extensible: Easily register additional parsers.
- Dependency Injection Ready: Works seamlessly with PSR-11 containers.
- Merge Strategies: Replace, merge, or ignore existing configuration values.
- Dot-Notation Access: Retrieve nested configuration values effortlessly.
Installation
Install via Composer:
Usage
Initialize ConfigManager
Load Configuration Files
Access Configuration Values
Modify Configuration
Convert Configuration to Array
Supported Formats
By default, comphp/config
supports:
- JSON (
.json
) - PHP (
.php
returning an array)
You can register additional parsers using ParserRegistry
.
Extending with Custom Parsers
Merge Strategies
When loading configurations, you can define how new values are merged:
MergeMode::Replace
(default): Overwrites existing values.MergeMode::Merge
: Merges arrays recursively.MergeMode::Ignore
: Keeps existing values untouched.MergeMode::Error
: Throws an exception if a key already exists.
Example:
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
See CONTRIBUTING.md for guidelines on how to contribute.
Changelog
See CHANGELOG.md for a history of updates.