Skip to content
Muhammet Şafak edited this page May 29, 2026 · 2 revisions

InitPHP Config — Wiki

Welcome to the official documentation for initphp/config — an advanced configuration manager that gives PHP applications a single, uniform API over configuration loaded from arrays, PHP files, whole directories, and class/object properties, with dotted-path access and case-insensitive keys.

It is built on top of initphp/parameterbag, which provides the underlying nested store.

The package ships three entry points that all share the same read/write contract:

Type Purpose
Classes Turn a class's own properties into configuration.
Library An injectable object with the full loader API.
Config A static facade over a shared Library singleton.

All three implement ConfigInterface, so get / set / has / remove / all behave identically wherever you use them.

composer require initphp/config
use InitPHP\Config\Config;

Config::setArray('app', [
    'name' => 'demo',
    'db'   => ['host' => 'localhost', 'user' => 'root'],
]);

Config::get('app.name');               // 'demo'
Config::get('app.db.host');            // 'localhost'
Config::get('app.db.charset', 'utf8'); // 'utf8' (default — key absent)
Config::get('APP.DB.HOST');            // 'localhost' (case-insensitive)

Start here

At a glance — entry-point matrix

Capability Classes Library Config
get / set / has / remove / all ✅ ✅ ✅
Dotted-path keys (db.host) ✅ ✅ ✅
Case-insensitive keys ✅ ✅ ✅
Initial data source subclass properties constructor / loaders loaders
Load array — setArray() ❌ ✅ ✅
Load PHP file — setFile() ❌ ✅ ✅
Load directory — setDir() ❌ ✅ ✅
Load class/object — setClass() ❌ ✅ ✅
Replace whole tree — replace() ❌ ✅ ✅
Object-style access ($cfg->db->host) ❌ ✅ ❌
Lifetime per instance per instance process-wide singleton

Package metadata

If something in this wiki is unclear, ambiguous, or wrong, please open an issue — documentation fixes are reviewed eagerly.

Clone this wiki locally