\Cake\Core\Configure\EngineIniConfig

Ini file configuration engine.

Since IniConfig uses parse_ini_file underneath, you should be aware that this class shares the same behavior, especially with regards to boolean and null values.

In addition to the native parse_ini_file features, IniConfig also allows you to create nested array structures through usage of . delimited names. This allows you to create nested arrays structures in an ini config file. For example:

db.password = secret would turn into ['db' => ['password' => 'secret']]

You can nest properties as deeply as needed using .'s. In addition to using . you can use standard ini section notation to create nested structures:

[section]
key = value

Once loaded into Configure, the above would be accessed using:

`Configure::read('section.key');

You can also use . separated values in section names to create more deeply nested structures.

IniConfig also manipulates how the special ini values of 'yes', 'no', 'on', 'off', 'null' are handled. These values will be converted to their boolean equivalents.

Summary

Methods
Properties
Constants
__construct()
read()
dump()
No public properties found
No constants found
_getFilePath()
_parseNestedValues()
_value()
$_path
$_extension
$_section
N/A
No private methods found
No private properties found
N/A

Properties

$_path

$_path : string

The path this engine finds files on.

Type

string

$_extension

$_extension : string

File extension.

Type

string

$_section

$_section : string|null

The section to read, if null all sections will be read.

Type

string|null

Methods

__construct()

__construct(string|null  $path = null, string|null  $section = null) 

Build and construct a new ini file parser. The parser can be used to read ini files that are on the filesystem.

Parameters

string|null $path

Path to load ini config files from. Defaults to CONFIG.

string|null $section

Only get one section, leave null to parse and fetch all sections in the ini file.

read()

read(string  $key) : array

Read an ini file and return the results as an array.

This method is used for reading configuration information from sources. These sources can either be static resources like files, or dynamic ones like a database, or other datasource.

Parameters

string $key

The identifier to read from. If the key has a . it will be treated as a plugin prefix. The chosen file must be on the engine's path.

Throws

\Cake\Core\Exception\Exception

when files don't exist. Or when files contain '..' as this could lead to abusive reads.

Returns

array —

Parsed configuration values.

dump()

dump(string  $key, array  $data) : boolean

Dumps the state of Configure data into an ini formatted string.

Parameters

string $key

The identifier to write to. If the key has a . it will be treated as a plugin prefix.

array $data

The data to convert to ini file.

Returns

boolean —

Success.

_getFilePath()

_getFilePath(string  $key, boolean  $checkExists = false) : string

Get file path

Parameters

string $key

The identifier to write to. If the key has a . it will be treated as a plugin prefix.

boolean $checkExists

Whether to check if file exists. Defaults to false.

Throws

\Cake\Core\Exception\Exception

When files don't exist or when files contain '..' as this could lead to abusive reads.

Returns

string —

Full file path

_parseNestedValues()

_parseNestedValues(array  $values) : array

parses nested values out of keys.

Parameters

array $values

Values to be exploded.

Returns

array —

Array of values exploded

_value()

_value(mixed  $value) : string

Converts a value into the ini equivalent

Parameters

mixed $value

Value to export.

Returns

string —

String value for ini file.