JSON engine allows Configure to load configuration values from files containing JSON strings.
An example JSON file would look like::
{ "debug": false, "App": { "namespace": "MyApp" }, "Security": { "salt": "its-secret" } }
$_extension
protected string
Converts the provided $data into a JSON string that can be used saved into a file and loaded later.
__construct( string|null $path null )
Constructor for JSON Config file reading.
$path
optional null dump( string $key , array $data )
Converts the provided $data into a JSON string that can be used saved into a file and loaded later.
$key
The identifier to write to. If the key has a . it will be treated as a plugin prefix.
$data
Cake\Core\Configure\ConfigEngineInterface::dump()
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 Plugin::path().
$key
The identifier to read from. If the key has a . it will be treated as a plugin prefix.
Cake\Core\Exception\Exception
When files don't exist or when files contain '..' (as this could lead to abusive reads) or when there is an error parsing the JSON string.
Cake\Core\Configure\ConfigEngineInterface::read()
_getFilePath( string $key , boolean $checkExists false )
Get file path
$key
The identifier to write to. If the key has a . it will be treated as a plugin prefix.
$checkExists
optional false Cake\Core\Exception\Exception
When files don't exist or when files contain '..' as this could lead to abusive reads.
© 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/3.5/class-Cake.Core.Configure.Engine.JsonConfig.html