functions.php

File

This file is part of php-fast-forward/config.

Description

This source file is subject to the license bundled with this source code in the file LICENSE.

Tags
copyright

Description

Copyright (c) 2025-2026 Felipe Sayão Lobato Abreu github@mentordosnerds.com

license

Description

https://opensource.org/licenses/MIT MIT License

Table of Contents

Functions

config()

Creates a unified configuration object from various sources.

 : ConfigInterface
configCache()

Creates a cached configuration object from various sources.

 : ConfigInterface
configDir()

Creates a directory-based configuration provider.

 : ConfigInterface
configProvider()

Creates a configuration from a list of Laminas-style configuration providers.

 : ConfigInterface
Functions

Functions

config()

Creates a unified configuration object from various sources.

config( array<string|int, mixed>|ConfigInterface|string  ...$configs) : ConfigInterface

Description

This function SHALL normalize and aggregate mixed input types such as arrays, directories, and Laminas configuration providers into a single configuration instance.

Parameters
$configs : array<string|int, mixed>|ConfigInterface|string

Description

The configuration sources.

Return values

Description

the aggregated configuration instance

configCache()

Creates a cached configuration object from various sources.

configCache(CacheInterface  $cache, array<string|int, mixed>|ConfigInterface|string  ...$configs) : ConfigInterface

Description

This function SHALL wrap the configuration in a caching layer using PSR-16 CacheInterface.

Parameters
$cache : CacheInterface

Description

the cache pool for storing configuration data

$configs : array<string|int, mixed>|ConfigInterface|string

Description

The configuration sources.

Return values

Description

the cached configuration instance

configDir()

Creates a directory-based configuration provider.

configDir( string  $rootDirectory[, bool  $recursive = false][, string|null  $cachedConfigFile = null]) : ConfigInterface

Description

If the recursive flag is TRUE, nested directories SHALL be included in the scan. Configuration files MUST follow the PHP file format.

Parameters
$rootDirectory : string

Description

the directory to load configuration files from

$recursive : bool = false

Description

whether to include files in subdirectories recursively

$cachedConfigFile : string|null = null

Description

optional path to a cache file for the configuration

Return values

Description

the resulting configuration provider instance

configProvider()

Creates a configuration from a list of Laminas-style configuration providers.

configProvider( iterable<string|int, mixed>  $providers[, string|null  $cachedConfigFile = null]) : ConfigInterface

Description

Each provider MUST be invokable and return an array or configuration structure.

Parameters
$providers : iterable<string|int, mixed>

Description

a list of configuration providers

$cachedConfigFile : string|null = null

Description

optional path to a cache file for the configuration

Return values

Description

the resulting configuration instance