Skip to content
docsv0.1.0

Config

Read-only application configuration bag, resolved from `Kernel::boot()`'s `config` key and registered in the container as `Config::class`. This is the seam plugins use to receive configuration WITHOUT constructor arguments: the {@see \Milpa\Interfaces\Plugin\PluginInterface} contract fixes the constructor to `(DIContainerInterface $container)`, so a plugin that needs a value (a storage path, an API base URL) reads it here in `boot()` — `$container->get(Config::class)->get('storage.path')` — rather than through an env var or a widened constructor. Dot-notation keys index nested arrays.

Config::__construct()

public function __construct(array $values = []):

Parameters

Parameters of __construct()
NameTypeDescription
$valuesarray<string, mixed>

Config::get()

public function get(string $key, ?mixed $default = null): ?mixed

Read a value by dot-notation key (`'storage.path'` walks `$values['storage']['path']`). Returns `$default` if any segment is missing or not an array mid-path.

Parameters

Parameters of get()
NameTypeDescription
$keystring
$default?mixed

Config::has()

public function has(string $key): bool

True if the dot-notation key resolves to a set value (even `null`).

Parameters

Parameters of has()
NameTypeDescription
$keystring

Config::all()

public function all(): array

Returns

The whole bag.