Config
Reference for the Config module: register and read typed, per-module configuration values. Modules declare the values they need; the application provides them up front; a security check confirms nothing required is missing before a request is served.
This page is a pure reference. For how a site provides its configuration, see the guide: Configuration.
Config- register and read typed, per-module configuration values.
Config
Register the configuration a module needs, read the values the application provided, and verify that everything required is present. Values are keyed by module and value name, and are typed with the constants below.
Constants
| Constant | Value | Description |
|---|---|---|
Config::TYPE_STRING | 'string' | A string value. |
Config::TYPE_INTEGER | 'integer' | A whole number. |
Config::TYPE_FLOAT | 'float' | A decimal number. |
Config::TYPE_BOOLEAN | 'boolean' | A true or false value. |
Config::TYPE_CALLABLE | 'callable' | A callable value. |
Config::TYPE_STRING_ARRAY | 'string_array' | A list of strings. |
Call
Config::Call(string $moduleName, string $valueName, mixed ...$args): mixed
Get a config value that is a callable and invoke it with the given arguments.
| Name | Type | Description |
|---|---|---|
$moduleName | string | The module that registered the value. |
$valueName | string | The config value name; must hold a callable. |
...$args | mixed | The arguments passed to the callback. |
Returns mixed The value returned by the callback.
Get
Config::Get(string $moduleName, string $valueName): mixed
Get a registered config value: the provided value, or the optional default. Throws when a required value was not provided.
| Name | Type | Description |
|---|---|---|
$moduleName | string | The module that registered the value. |
$valueName | string | The config value name. |
Returns mixed The configuration value.
GetModules
Config::GetModules(): array
The names of all modules that have registered config, sorted.
Returns array A list of module names.
GetModuleValues
Config::GetModuleValues(string $moduleName): array
Every registered config value for a module, keyed by value name.
| Name | Type | Description |
|---|---|---|
$moduleName | string | The module to read values for. |
Returns array A map of value name to value.
GetOptional
Config::GetOptional(string $moduleName, string $valueName, mixed $defaultValue): mixed
Get a provided config value, or the given default when it was not provided.
| Name | Type | Description |
|---|---|---|
$moduleName | string | The module that registered the value. |
$valueName | string | The config value name. |
$defaultValue | mixed | The value to return when none was provided. |
Returns mixed The configuration value, or the default.
GetSchema
Config::GetSchema(?string $moduleName = null): array
The registered config schema entries, optionally filtered to one module.
| Name | Type | Description |
|---|---|---|
$moduleName | ?string | A module name to filter by, or null for every entry. |
Returns array The schema entries.
Optional
Config::Optional(string $moduleName, string $valueName, string $valueType, mixed $defaultValue): void
Register an optional config value with a default. Idempotent when re-registered with the same type.
| Name | Type | Description |
|---|---|---|
$moduleName | string | The module registering the value. |
$valueName | string | The config value name. |
$valueType | string | One of the Config type constants. |
$defaultValue | mixed | The value used when none is provided. |
Returns void
Provide
Config::Provide(string $moduleName, array $configArray): void
Supply config values for a module, as a map of value name to value. Called by the application before modules load; types are checked later by SecurityCheck.
| Name | Type | Description |
|---|---|---|
$moduleName | string | The module the values belong to. |
$configArray | array | A map of value name to value; nested arrays are not allowed. |
Returns void
Required
Config::Required(string $moduleName, string $valueName, string $valueType): void
Register a required config value. Idempotent when re-registered with the same type.
| Name | Type | Description |
|---|---|---|
$moduleName | string | The module registering the value. |
$valueName | string | The config value name. |
$valueType | string | One of the Config type constants. |
Returns void
SecurityCheck
Config::SecurityCheck(): void
Verify every required config value was provided and every provided value matches its registered type. Run after all modules load; throws listing anything missing.
Returns void