Config
final class Config (View source)
Mutable runtime configuration store for framework and application settings.
The store supports dot-notation keys, provides both generic and typed access
helpers, and allows direct setting and recursive merging of configuration
values. The framework.providers branch uses replace-only merge semantics
and is not merged by numeric indexes.
Methods
Creates a configuration store with optional initial items.
Returns the complete current configuration state.
Returns a configuration value resolved through dot notation.
Returns a required configuration value.
Returns the resolved configuration value converted to a string when possible.
Returns a required non-empty string configuration value.
Returns the resolved configuration value as an integer.
Returns the resolved configuration value as a boolean.
Returns the resolved configuration value when it is an array.
Sets a configuration value through dot notation.
Recursively merges configuration values into the current state.
Details
__construct
__construct(array $items = [])
Creates a configuration store with optional initial items.
all
array
all()
Returns the complete current configuration state.
get
mixed
get(string $key, mixed $default = null)
Returns a configuration value resolved through dot notation.
When any path segment is missing, the provided default value is returned.
If the key exists and its value is explicitly null, null is returned.
require
mixed
require(string $key)
Returns a required configuration value.
Values such as false, 0, an empty string, and an empty array are
accepted. Only missing or explicit null values are treated as absent.
string
string|null
string(string $key, string|null $default = null)
Returns the resolved configuration value converted to a string when possible.
Scalar values are cast to string. When the resolved value is null or is
not scalar, the method returns null. The default value is used when the
key path does not exist.
requiredString
string
requiredString(string $key)
Returns a required non-empty string configuration value.
int
int
int(string $key, int $default = 0)
Returns the resolved configuration value as an integer.
Native integers are returned unchanged. Floats and numeric strings are cast to integers. Any other value falls back to the provided default.
bool
bool
bool(string $key, bool $default = false)
Returns the resolved configuration value as a boolean.
The method uses PHP boolean validation semantics for scalar values and
falls back to the provided default for invalid or non-scalar input.
Common textual boolean representations such as "true" and "false"
are supported.
array
array
array(string $key, array $default = [])
Returns the resolved configuration value when it is an array.
set
void
set(string $key, mixed $value)
Sets a configuration value through dot notation.
Missing intermediate segments are created as arrays. Existing intermediate non-array values are replaced with arrays before traversal.
merge
void
merge(array $items)
Recursively merges configuration values into the current state.
Incoming values override existing ones through array_replace_recursive.
The framework.providers branch is replaced as a whole instead of being
merged by indexes.