Download the PHP package dikki/config without Composer
On this page you can find all versions of the php package dikki/config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package 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
- 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
To install Dikki Config, use Composer:
Usage
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
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
First, ensure that you have a config folder in your project. Add all your config files in this folder.
Example
OUTPUT: UTC
More Details
ConfigFetcher Class
The ConfigFetcher
class is designed to recursively search for and parse all supported configuration file formats within a given directory.
Constructor
path
: The path to the directory containing configuration files.
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
The Config
class takes an instance of a class implementing ConfigInterface
and delegates the get()
method to it.
Constructor
parser
: An instance of a class implementingConfigInterface
.
Methods
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
Each parser class implements the ConfigInterface
and provides methods to parse specific file formats.
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
Parses .env
files.
IniParser
Parses INI files.
JsonParser
Parses JSON files.
NeonParser
Parses Neon files.
PhpArrayParser
Parses PHP array files.
YamlParser
Parses YAML files.
Testing
To test the functionality of the Dikki Config library, you can use the provided test cases coded using Nette Tester.
License
This project is licensed under the MIT License - see the LICENSE file for details.