Download the PHP package cklamm/config without Composer
On this page you can find all versions of the php package cklamm/config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cklamm/config
More information about cklamm/config
Files in cklamm/config
Package config
Short Description PHP Config
License MIT
Homepage https://github.com/cklamm/php-config
Informations about the package config
PHP Config
This small library makes it easy to read configuration variables from PHP files.
Contents
- Installation
- ConfigFile
- ConfigFolder
Installation
The library can be installed via Composer.
ConfigFile
This class reads configuration variables from a single PHP file, which must return an associative array. Consider the following example.
The file name is passed to the constructor of ConfigFile
.
The method get($name)
is used to access the configuration variables.
- If
$name
equals*
, the whole array is returned. - If
$name
exists as a key, the corresponding value is returned. - If
$name
ends with.*
, an array is returned containing all entries whose key starts with$name
(minus the asterisk). The$name
part is removed from the keys. If there are no matching keys, the returned array will be empty. - Else
null
is returned.
ConfigFolder
This class reads configuration variables from a folder containing multiple PHP files. Each file must return an associative array. For example, we could have the following two files in a config
folder.
The folder name is passed to the constructor of ConfigFolder
.
The method get($name)
is used to access the configuration variables. The part of $name
before the first .
corresponds to the file name.
- If
$name
contains no.
,null
is returned. - If no corresponding file exists,
null
is returned. - Otherwise it behaves similarly to the
get
method ofConfigFile
.