Download the PHP package yosymfony/config-loader without Composer
On this page you can find all versions of the php package yosymfony/config-loader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package config-loader
Config loader for PHP
An agnostics configuration loader with built-in loaders for YAML, TOML and JSON.
Installation
Requires PHP >= 7.2.
Use Composer to install this package:
Usage
Initialization
The class ConfigLoader
let you load your configuration resources. It expects a list of
loaders in the constructor so you can pass to it only those ones you need:
Available loaders
Yaml loader
Requires: Symfony YAML component:
Initialization:
Toml loader
Requires: Toml component:
Initialization:
Json loader
Initialization:
Loading configuration files:
.dist files
This library has support for .dist
files. The filename is resolved following the next hierarchy:
- filename.ext
- filename.ext.dist (if
filename.ext
does not exist)
Loading inline configuration:
To parse inline configurations you just need to set the configuration text as first argument instead of the filename and set the format type as second one:
Importing files
This library has support for importing files. The example below shows a YAML file importing three files:
Similar example using JSON syntax:
An example using TOML syntax:
Repository
A configuration file is loaded into a repository. A repository is a wrapper that implements the ArrayAccess interface and exposes methods for working with configuration values.
Operations
Unions
You can performs the union of a repository A with another B into C as result:
The values of $repositoryB
have less priority than values in $repositoryA
.
Intersections
You can performs the intersection of a repository A with another B into C as result:
The values of $repositoryB
have less priority than values in $repositoryA
.
Creating a blank repository
Creating a blank repository is too easy. You just need to create a instance of
a Repository
class:
Unit tests
You can run the unit tests with the following command:
License
This library is open-sourced software licensed under the MIT license.