pop-config
is a basic configuration component that helps centralize application
configuration values and parameters. Values can be accessed via array notation or
object arrow notation. It can disable changes to the configuration values if need
be for the life-cycle of the application. It also can parse configuration values
from common formats, such as JSON, XML, INI and YAML.
pop-config
is a component of the Pop PHP Framework.
Install pop-config
using Composer.
composer require popphp/pop-config
Or, require it in your composer.json file
"require": {
"popphp/pop-config" : "^4.0.3"
}
use Pop\Config\Config;
$config = new Config(['foo' => 'bar']);
$foo = $config->foo;
// OR
$foo = $config['foo'];
Changes to configuration values are disabled by default.
use Pop\Config\Config;
$config = new Config(['foo' => 'bar'], true);
$config->foo = 'New Value';
use Pop\Config\Config;
$config = new Config($configData);
$config->merge($newData);
use Pop\Config\Config;
$config = new Config($configData);
$data = $config->toArray();
; This is a sample configuration file config.ini
[foo]
bar = 1
baz = 2
use Pop\Config\Config;
$config = Config::createFromData('/path/to/config.ini');
// $value equals 1
$value = $config->foo->bar;
Supported formats include PHP, JSON, XML, INI and YAML
use Pop\Config\Config;
$config = new Config($configData);
echo $config->render('json');