RecursiveDirectoryConfig

Class
extends DirectoryConfig
Final: Yes

Class RecursiveDirectoryConfig.

Description

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.

Table of Contents

Constants

 = '{*,**/*}.php'

Properties

Methods

__construct()

Constructs a DirectoryConfig instance.

 : mixed
__invoke()

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

 : ConfigInterface
get()

Retrieves a configuration value by key.

 : mixed
getIterator()

Retrieves an iterator for traversing the configuration data.

 : Traversable
has()

Checks for existence of a configuration key.

 : bool
remove()

Removes a configuration key.

 : void
set()

Sets configuration data.

 : void
toArray()

Exports the entire configuration to an array.

 : array<string|int, mixed>
getConfig()

Retrieves or initializes the configuration instance.

 : ConfigInterface
Constants

Constants

PATTERN

Protected
protected string PATTERN = '{*,**/*}.php'

Description

Recursive pattern to match all *.php files in all nested directories.

Properties
Methods

__construct()

Public

Constructs a DirectoryConfig instance.

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

Description

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
$directory : string

Description

the directory path from which to load configuration files

$cachedConfigFile : string|null = null

Description

optional path to a cache file for the aggregated configuration

Tags
throws

Description

if the directory is not valid or not readable

__invoke()

Public Abstract

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

public abstract __invoke() : ConfigInterface
Return values

Description

the actual configuration instance

get()

Public

Retrieves a configuration value by key.

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

Description

the configuration key to retrieve

$default : mixed|null = null

Description

the default value if the key is not found

Return values

Description

the value of the configuration key or the default

getIterator()

Public

Retrieves an iterator for traversing the configuration data.

public getIterator() : Traversable
Return values
Traversable

Description

an iterator over the configuration

has()

Public

Checks for existence of a configuration key.

public has( string  $key) : bool
Parameters
$key : string

Description

the configuration key to check

Return values
bool

Description

TRUE if the key exists, FALSE otherwise

remove()

Public

Removes a configuration key.

public remove( string  $key) : void
Parameters
$key : string

Description

the configuration key to remove

set()

Public

Sets configuration data.

public set( array<string|int, mixed>|ConfigInterface|string  $key[, mixed|null  $value = null]) : void
Parameters
$key : array<string|int, mixed>|ConfigInterface|string

Description

the key or set of keys/values to set

$value : mixed|null = null

Description

the value to set if a single key is provided

toArray()

Public

Exports the entire configuration to an array.

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

Description

the configuration as an associative array