-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Muhammet Şafak edited this page May 24, 2026
·
2 revisions
Welcome to the official documentation for initphp/parameterbag — a small,
dependency-free container that gives PHP applications a uniform, default-aware API
over both flat key/value data and nested (dotted-path) structures.
The package ships two types:
| Type | Purpose |
|---|---|
ParameterBag |
The default concrete implementation; open for extension. |
ParameterBagInterface |
The contract — depend on this in your services. |
Both types satisfy PHP's standard collection contracts —
ArrayAccess, Countable, IteratorAggregate — so the bag drops into any
code that consumes those interfaces.
composer require initphp/parameterbaguse InitPHP\ParameterBag\ParameterBag;
$config = new ParameterBag([
'app' => ['name' => 'demo', 'debug' => false],
'db' => ['dsn' => 'mysql:host=localhost', 'user' => 'root'],
]);
$config->get('app.name'); // 'demo'
$config->get('db.charset', 'utf8mb4'); // 'utf8mb4' (default)
$config->set('app.debug', true)->merge(['db' => ['pass' => 'secret']]);- New to the package? Read Installation, then Quick Start.
- Building a config tree? See Nested Data and the Config Loader recipe.
-
Wrapping
$_GET/$_POST? Read the Request Parameters recipe. - Injecting into a container? Read Dependency Injection.
- Upgrading from v1? Read the Migration Guide.
- Looking for a specific method? The full API Reference lists every class member.
| Capability | Flat mode (isMulti = false) |
Multi mode (isMulti = true) |
|---|---|---|
get / set / has / remove of top-level keys |
✅ | ✅ |
Dotted-path access (db.user) |
❌ (dot is part of the key) | ✅ |
| Configurable separator | n/a | ✅ ('.' default) |
| Case-insensitive keys (opt-in) | ✅ | ✅ |
| Merge strategy |
array_merge (shallow) |
array_replace_recursive (deep) |
ArrayAccess $bag['x']
|
✅ | ✅ (path supported) |
Countable / IteratorAggregate
|
top-level entries only | top-level entries only |
| Strict option validation (unknown keys throw) | ✅ | ✅ |
| Null values distinguishable from missing | ✅ | ✅ |
- License: MIT
- Minimum PHP: 7.4 (also tested on 8.0 – 8.4)
- Runtime dependencies: none
-
Packagist:
initphp/parameterbag - Source: github.com/InitPHP/ParameterBag
- Issues: github.com/InitPHP/ParameterBag/issues
- Discussions: github.com/orgs/InitPHP/discussions
-
Security:
SECURITY.md
If something in this wiki is unclear, ambiguous, or wrong, please open an issue — documentation fixes are reviewed eagerly.
initphp/parameterbag · MIT License · part of the InitPHP family
Source · Issues · Discussions · Packagist · Contributing · Security Policy
Getting Started
Core Usage
Reference
Practical Guides
Migration & Help