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

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

borschphp/config
================

A minimal configuration manager.

1.4.2(1mo ago)0562MITPHPPHP ^8.3CI passing

Since Sep 3Pushed 1mo agoCompare

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

READMEChangelog (10)Dependencies (13)Versions (17)Used By (2)

Borsch Config
=============

[](#borsch-config)

A lightweight and easy to use configuration library.

Features
--------

[](#features)

- Simple and intuitive API
- Support for multiple file formats (JSON, YAML, INI, DOTENV)
- Aggregate multiple configuration sources
- Caching for improved performance in production

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

[](#installation)

Via [composer](https://getcomposer.org) :

```
composer require borschphp/config
```

Usage
-----

[](#usage)

The `Config` class implements the `ContainerInterface` from PSR-11, therefore you have access to all its methods to check if a key exists and to retrieve its value.
A `getOrDefault()` method is also available to provide a default value if the key does not exist.

Internally, readers are used to parse configuration files of different formats. The following readers are available:

- `Borsch\Config\Reader\Json` for JSON files
- `Borsch\Config\Reader\Yaml` for YAML files (via `symfony/yaml`)
- `Borsch\Config\Reader\Ini` for INI files
- `Borsch\Config\Reader\DotEnv` for DOTENV files (via `vlucas/phpdotenv`)

The `Aggregator` class allows you to merge multiple configuration sources into a single `Config` instance. You can also provide a cache file path to store the merged configuration for faster access in production environments.

A simple example with just one reader :

```
