Pop Config Component for Pop PHP Framework

3.4.0 2021-02-12 02:43 UTC

This package is auto-updated.

Last update: 2021-09-12 03:55:08 UTC


Build Status Coverage Status


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, INI and XML.

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" : "3.0.*"


Set and access values

$config = new Pop\Config\Config(['foo' => 'bar']);

$foo = $config->foo;
// OR
$foo = $config['foo'];

Allow changes

Changes to configuration values are disabled by default.

$config = new Pop\Config\Config(['foo' => 'bar'], true);
$config->foo = 'New Value';

Parse a configuration file

; This is a sample configuration file config.ini
bar = 1
baz = 2
$config = new Pop\Config\Config('/path/to/config.ini');

// $value equals 1
$value = $config->foo->bar;

Merge new values into the config object

$config = new Pop\Config\Config($configData);

Convert config object down to a basic array

$config = new Pop\Config\Config($configData);
$data   = $config->toArray();