Class IniReader
Ini file configuration engine.
Since IniReader 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, IniReader 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 array('db' => array('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 combine .
separated values with sections to create more deeply nested structures.
IniReader also manipulates how the special ini values of 'yes', 'no', 'on', 'off', 'null' are handled. These values will be converted to their boolean equivalents.
- IniReader implements ConfigReaderInterface
See: http://php.net/parse_ini_file
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/Configure/IniReader.php
Properties summary
-
$_path
protectedThe path to read ini files from.array
-
$_section
protectedThe section to read, if null all sections will be read.string
Method Summary
- __construct() public
Build 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()source public
__construct( string $path null , string $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
$path
optional null - Path to load ini config files from. Defaults to CONFIG
- string
$section
optional null Only get one section, leave null to parse and fetch all sections in the ini file.
_getFilePath()source protected
_getFilePath( string $key )
Get file path
Parameters
- string
$key
The identifier to write to. If the key has a . it will be treated as a plugin prefix.
Returns
stringFull file path
_parseNestedValues()source protected
_parseNestedValues( array $values )
parses nested values out of keys.
Parameters
- array
$values
- Values to be exploded.
Returns
arrayArray of values exploded
_value()source protected
_value( mixed $val )
Converts a value into the ini equivalent
Parameters
- mixed
$val
- Value to export.
Returns
stringString value for ini file.
dump()source public
dump( string $key , array $data )
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
integerBytes saved.
Implementation of
ConfigReaderInterface::dump()
read()source public
read( string $key )
Read an ini file and return the results as an array.
For backwards compatibility, acl.ini.php will be treated specially until 3.0.
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 reader's path.
Returns
arrayParsed configuration values.
Throws
ConfigureException
when files don't exist. Or when files contain '..' as this could lead to abusive reads.
Implementation of
ConfigReaderInterface::read()
Properties detail
© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/2.10/class-IniReader.html