Class PhpReader
PHP Reader allows Configure to load configuration values from files containing simple PHP arrays.
Files compatible with PhpReader should define a $config
variable, that contains all of the configuration data contained in the file.
- PhpReader implements ConfigReaderInterface
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/Configure/PhpReader.php
Properties summary
-
$_path
protectedThe path this reader finds files on.string
Method Summary
- __construct() publicConstructor for PHP Config file reading.
- _getFilePath() protectedGet file path
- dump() public
Converts the provided $data into a string of PHP code that can be used saved into a file and loaded later.
- read() publicRead a config file and return its contents.
Method Detail
__construct()source public
__construct( string $path null )
Constructor for PHP Config file reading.
Parameters
- string
$path
optional null - The path to read config files from. Defaults to CONFIG
_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
dump()source public
dump( string $key , array $data )
Converts the provided $data into a string of PHP code that can be used saved into a file and loaded later.
Parameters
- string
$key
The identifier to write to. If the key has a . it will be treated as a plugin prefix.
- array
$data
- Data to dump.
Returns
integerBytes saved.
Implementation of
ConfigReaderInterface::dump()
read()source public
read( string $key )
Read a config file and return its contents.
Files with .
in the name will be treated as values in plugins. Instead of reading from the initialized path, plugin keys will be located using CakePlugin::path().
Parameters
- string
$key
The identifier to read from. If the key has a . it will be treated as a plugin prefix.
Returns
arrayParsed configuration values.
Throws
ConfigureException
when files don't exist or they don't contain $config
. 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-PhpReader.html