Skip to content

RecursiveDirectoryConfig

github-actions edited this page Mar 27, 2026 · 1 revision

Class RecursiveDirectoryConfig.

Extends DirectoryConfig to support recursive loading of configuration files from a root directory. This class SHALL match both top-level and nested PHP files using a recursive glob pattern.


  • Full name: \FastForward\Config\RecursiveDirectoryConfig
  • Parent class: \FastForward\Config\DirectoryConfig
  • This class is marked as final and can't be subclassed
  • This class is a Final class

Constants

Constant Visibility Type Value
PATTERN protected string '{,**/}.php'

Inherited methods

__invoke

Implementing class MUST define the __invoke() method to return a ConfigInterface instance.

public __invoke(): \FastForward\Config\ConfigInterface
  • This method is abstract. Return Value:

the actual configuration instance


get

Retrieves a configuration value by key.

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

Parameters:

Parameter Type Description
$key string the configuration key to retrieve
$default mixed|null the default value if the key is not found

Return Value:

the value of the configuration key or the default


has

Checks for existence of a configuration key.

public has(string $key): bool

Parameters:

Parameter Type Description
$key string the configuration key to check

Return Value:

TRUE if the key exists, FALSE otherwise


set

Sets configuration data.

public set(array|\FastForward\Config\ConfigInterface|string $key, mixed|null $value = null): void

Parameters:

Parameter Type Description
$key array|\FastForward\Config\ConfigInterface|string the key or set of keys/values to set
$value mixed|null the value to set if a single key is provided

remove

Removes a configuration key.

public remove(string $key): void

Parameters:

Parameter Type Description
$key string the configuration key to remove

toArray

Exports the entire configuration to an array.

public toArray(): array

Return Value:

the configuration as an associative array


getIterator

Retrieves an iterator for traversing the configuration data.

public getIterator(): \Traversable

Return Value:

an iterator over the configuration


__construct

Constructs a DirectoryConfig instance.

public __construct(string $directory, string|null $cachedConfigFile = null): mixed

This constructor SHALL validate the specified directory, and initialize the Laminas config aggregator with a PHP file provider using the defined pattern. If a cache file is provided, it SHALL be used to store the aggregated configuration.

Parameters:

Parameter Type Description
$directory string the directory path from which to load configuration files
$cachedConfigFile string|null optional path to a cache file for the aggregated configuration

Throws:

if the directory is not valid or not readable


Clone this wiki locally