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:

TypePurpose
ClassesTurn a class's own properties into configuration.
LibraryAn injectable object with the full loader API.
ConfigA 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
useInitPHP\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

CapabilityClassesLibraryConfig
get / set / has / remove / all
Dotted-path keys (db.host)
Case-insensitive keys
Initial data sourcesubclass propertiesconstructor / loadersloaders
Load array — setArray()
Load PHP file — setFile()
Load directory — setDir()
Load class/object — setClass()
Replace whole tree — replace()
Object-style access ($cfg->db->host)
Lifetimeper instanceper instanceprocess-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