Class IniConfig
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 = valueOnce loaded into Configure, the above would be accessed using:
`Configure::read('section.key');
You can combine . separated values with sections 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.
Property Summary
- 
        $_extension protectedstringFile extension. 
- 
        $_path protectedstringThe path this engine finds files on. 
- 
        $_section protectedstringThe section to read, if null all sections will be read. 
Method Summary
- 
          __construct() publicBuild and construct a new ini file parser. The parser can be used to read ini files that are on the filesystem. 
- 
          _getFilePath() protectedGet file path 
- 
          _parseNestedValues() protectedparses nested values out of keys. 
- 
          _value() protectedConverts a value into the ini equivalent 
- 
          dump() publicDumps the state of Configure data into an ini formatted string. 
- 
          read() publicRead an ini file and return the results as an array. 
Method Detail
__construct() ¶ public
__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 optional
- Path to load ini config files from. Defaults to CONFIG. 
- 
                string|null$section optional
- Only get one section, leave null to parse and fetch all sections in the ini file. 
_getFilePath() ¶ protected
_getFilePath(string $key, bool $checkExists = false): stringGet file path
Parameters
- 
                string$key
- The identifier to write to. If the key has a . it will be treated as a plugin prefix. 
- 
                bool$checkExists optional
- Whether to check if file exists. Defaults to false. 
Returns
stringFull file path
Throws
Cake\Core\Exception\ExceptionWhen files don't exist or when files contain '..' as this could lead to abusive reads.
_parseNestedValues() ¶ protected
_parseNestedValues(array $values): arrayparses nested values out of keys.
Parameters
- 
                array$values
- Values to be exploded. 
Returns
arrayArray of values exploded
_value() ¶ protected
_value(mixed $value): stringConverts a value into the ini equivalent
Parameters
- 
                mixed$value
- Value to export. 
Returns
stringString value for ini file.
dump() ¶ public
dump(string $key, array $data): boolDumps 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
boolSuccess.
read() ¶ public
read(string $key): arrayRead an ini file and return the results as an array.
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. 
Returns
arrayParsed configuration values.
Throws
Cake\Core\Exception\Exceptionwhen files don't exist. Or when files contain '..' as this could lead to abusive reads.
