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

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

dikki/config
============

Write and Parse Config Files in YAML, JSON, INI or PHP Array format

2.0.1(1y ago)236813MITPHPPHP &gt;=8.2

Since Sep 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/namankumar80510/DikkiConfig)[ Packagist](https://packagist.org/packages/dikki/config)[ RSS](/packages/dikki-config/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (5)Used By (3)

Dikki Config
============

[](#dikki-config)

**Disclosure: The documentation on this page was written with Claude AI**.

Dikki Config is a PHP library that allows you to create and manage configuration files for your PHP applications. It supports multiple file formats including PHP arrays, `.env` files, JSON, YAML, INI, and Neon. This library provides a unified interface to access configuration values regardless of the underlying file format.

Supported Parsers
-----------------

[](#supported-parsers)

- **PHP Array** (`Dikki\Config\PhpArrayParser`)
- **JSON** (`Dikki\Config\JsonParser`)
- **YAML** (`Dikki\Config\YamlParser`)
- **INI** (`Dikki\Config\IniParser`)
- **Neon** (`Dikki\Config\NeonParser`)
- **DotEnv** (`Dikki\Config\DotEnvParser`)

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

[](#installation)

To install Dikki Config, use Composer:

```
composer require dikki/config
```

Usage
-----

[](#usage)

### Multiple Config File Types

[](#multiple-config-file-types)

If you are using more than one type of configuration file, you can use the `ConfigFetcher` class to fetch and merge configurations from all supported file types.

#### Example of using ConfigFetcher Class

[](#example-of-using-configfetcher-class)

```
use Dikki\Config\ConfigFetcher;

$configFetcher = new ConfigFetcher(__DIR__ . '/config');

// Fetch all configurations
$config = $configFetcher->fetch();

// Get a specific configuration value using dot notation
echo $configFetcher->get('app.timezone');
```

### Individual Config File Types

[](#individual-config-file-types)

If you are using only one type of configuration file, you can use the `Config` class with the appropriate parser.

#### Create a Config File or Folder

[](#create-a-config-file-or-folder)

First, ensure that you have a config folder in your project. Add all your config files in this folder.

#### Example

[](#example)

```
use Dikki\Config\Config;
use Dikki\Config\YamlParser;

// Create an instance of the Config class
$config = new Config(new YamlParser(__DIR__ . '/config')); # pass either single file path or whole directory

// Get a configuration value (dot notation is supported)
echo $config->get('app.timezone');
```

**OUTPUT:** `UTC`

More Details
------------

[](#more-details)

### ConfigFetcher Class

[](#configfetcher-class)

The `ConfigFetcher` class is designed to recursively search for and parse all supported configuration file formats within a given directory.

#### Constructor

[](#constructor)

```
public function __construct(string $path)
```

- `path`: The path to the directory containing configuration files.

#### Methods

[](#methods)

- `fetch()`: Fetch and parse all supported config files.
- `getFiles(string $dir)`: Recursively get all files from the given directory.
- `mergeConfigs(array $baseConfig, array $newConfig)`: Merge two configuration arrays, preserving nested keys.
- `get(string $key, mixed $default = null)`: Get a specific configuration value by key using dot notation.

### Config Class

[](#config-class)

The `Config` class takes an instance of a class implementing `ConfigInterface` and delegates the `get()` method to it.

#### Constructor

[](#constructor-1)

```
public function __construct(ConfigInterface $parser)
```

- `parser`: An instance of a class implementing `ConfigInterface`.

#### Methods

[](#methods-1)

- `get(string $key, mixed $default = null)`: Get a value from the config array using dot notation.
- `getAll()`: Get all configuration values.
- `parse()`: Parse the configuration file(s) and return an array.

### Parser Classes

[](#parser-classes)

Each parser class implements the `ConfigInterface` and provides methods to parse specific file formats.

#### Common Methods

[](#common-methods)

- `parse()`: Parse the configuration file(s) and return an array.
- `get(string $key, mixed $default = null)`: Get a value from the config array using dot notation.

#### DotEnvParser

[](#dotenvparser)

Parses `.env` files.

#### IniParser

[](#iniparser)

Parses INI files.

#### JsonParser

[](#jsonparser)

Parses JSON files.

#### NeonParser

[](#neonparser)

Parses Neon files.

#### PhpArrayParser

[](#phparrayparser)

Parses PHP array files.

#### YamlParser

[](#yamlparser)

Parses YAML files.

Testing
-------

[](#testing)

To test the functionality of the Dikki Config library, you can use the provided test cases coded using Nette Tester.

```
use Dikki\Config\Config;
use Dikki\Config\ConfigFetcher;
use Dikki\Config\DotEnvParser;
use Dikki\Config\IniParser;
use Dikki\Config\JsonParser;
use Dikki\Config\NeonParser;
use Dikki\Config\PhpArrayParser;
use Dikki\Config\YamlParser;
use Tester\Assert;

require __DIR__ . '/vendor/autoload.php';

Tester\Environment::setup();

$configDir = __DIR__ . '/config';

$configFetcher = new ConfigFetcher($configDir);
$dotenvConfig = new Config(new DotEnvParser($configDir . '/.env'));
$iniConfig = new Config(new IniParser($configDir . '/iniconfig.ini'));
$jsonConfig = new Config(new JsonParser($configDir . '/jsonconfig.json'));
$neonConfig = new Config(new NeonParser($configDir . '/neonconfig.neon'));
$phpConfig = new Config(new PhpArrayParser($configDir . '/phpconfig.php'));
$yamlConfig = new Config(new YamlParser($configDir . '/yamlconfig.yaml'));

// Test individual parsers
Assert::equal($dotenvConfig->get('APP_NAME'), "Sample App");
Assert::equal($iniConfig->get('app.url'), "https://example.com");
Assert::equal($jsonConfig->get('app.author'), "Naman");
Assert::equal($neonConfig->get('app.debug'), false);
Assert::equal($phpConfig->get('app.timezone'), "Asia/Kolkata");
Assert::equal($yamlConfig->get('app.theme'), "Default");

// Test ConfigFetcher
Assert::equal($configFetcher->get('APP_NAME'), "Sample App");
Assert::equal($configFetcher->get('app.author'), "Naman");
Assert::equal($configFetcher->get('app.url'), "https://example.com");
Assert::equal($configFetcher->get('app.debug'), false);
Assert::equal($configFetcher->get('app.timezone'), "Asia/Kolkata");
Assert::equal($configFetcher->get('app.theme'), "Default");
```

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% 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 ~124 days

Total

4

Last Release

600d ago

Major Versions

1.0.1 → 2.0.02024-09-23

PHP version history (2 changes)1.0.0PHP 8.0 - 8.3

1.0.1PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/835b8766bb3b222a4f6dcc14eeafd4b7c09b1e1f50c20e3450a81905d099cb0a?d=identicon)[namankumar80510](/maintainers/namankumar80510)

---

Top Contributors

[![namankumar80510](https://avatars.githubusercontent.com/u/72571211?v=4)](https://github.com/namankumar80510 "namankumar80510 (6 commits)")[![harappanbook](https://avatars.githubusercontent.com/u/115454113?v=4)](https://github.com/harappanbook "harappanbook (1 commits)")

---

Tags

phpjsonarrayconfigyamldotenvini

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[jbzoo/data

An extended version of the ArrayObject object for working with system settings or just for working with data arrays

891.6M23](/packages/jbzoo-data)[zakirullin/mess

Convenient array-related routine &amp; better type casting

21228.9k2](/packages/zakirullin-mess)[hi-folks/data-block

Data class for managing nested arrays and JSON data.

1472.2k](/packages/hi-folks-data-block)[phppkg/config

Config manage, load, get. Supports INI,JSON,YAML,NEON,PHP format file

133.5k](/packages/phppkg-config)[davidepastore/slim-config

A slim middleware to read configuration from different files based on hassankhan/config

338.9k1](/packages/davidepastore-slim-config)[michaels/data-manager

Simple data manager for nested data, dot notation array access, extendability, and container interoperability.

121.9k2](/packages/michaels-data-manager)

PHPackages © 2026

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