Configuration class. Used for managing runtime configuration information.
Provides features for reading and writing to the runtime configuration, as well as methods for loading additional configuration files or storing runtime configuration for future use.
_getReader( string $config )
Get the configured reader. Internally used by Configure::load() and Configure::dump() Will create new PhpReader for default if not configured yet.
$config mixed_setErrorHandlers( array $error , array $exception )
Set the error and exception handlers.
$error $exception bootstrap( boolean $boot true )
Initializes configure and runs the bootstrap process. Bootstrapping includes the following steps:
$boot optional true check( string $var )
Returns true if given variable is set in Configure.
$var booleanconfig( string $name , ConfigReaderInterface $reader )
Add a new reader to Configure. Readers allow you to read configuration files in various formats/storage locations. CakePHP comes with two built-in readers PhpReader and IniReader. You can also implement your own reader classes in your application.
To add a new reader to Configure:
Configure::config('ini', new IniReader());
$name ConfigReaderInterface $reader configured( string|null $name null )
Gets the names of the configured reader objects.
$name optional null arrayconsume( string $var )
Used to read and delete a variable from Configure.
This is primarily used during bootstrapping to move configuration data out of configure into the various other classes in CakePHP.
$var array|nulldelete( string $var )
Used to delete a variable from Configure.
Usage:
Configure::delete('Name'); will delete the entire Configure::Name Configure::delete('Name.key'); will delete only the Configure::Name[key]
$var drop( string $name )
Remove a configured reader. This will unset the reader and make any future attempts to use it cause an Exception.
$name booleandump( string $key , string $config 'default' , array $keys array() )
Dump data currently in Configure into $key. The serialization format is decided by the config reader attached as $config. For example, if the 'default' adapter is a PhpReader, the generated file will be a PHP configuration file loadable by the PhpReader.
Given that the 'default' reader is an instance of PhpReader. Save all data in Configure to the file my_config.php:
Configure::dump('my_config.php', 'default');
Save only the error handling configuration:
Configure::dump('error.php', 'default', array('Error', 'Exception');
$key $config optional 'default' $keys optional array() booleanConfigureExceptiondump method.load( string $key , string $config 'default' , boolean $merge true )
Loads stored configuration information from a resource. You can add config file resource readers with Configure::config().
Loaded configuration information will be merged with the current runtime configuration. You can load configuration files from plugins by preceding the filename with the plugin name.
Configure::load('Users.user', 'default')
Would load the 'user' config file using the default config reader. You can load app config files by giving the name of the resource you want loaded.
Configure::load('setup', 'default');
If using default config and no reader has been configured for it yet, one will be automatically created using PhpReader
$key $config optional 'default' $merge optional true booleanConfigureExceptionread( string|null $var null )
Used to read information stored in Configure. It's not possible to store null values in Configure.
Usage:
Configure::read('Name'); will return all values for Name Configure::read('Name.key'); will return only the value of Configure::Name[key]
$var optional null mixedrestore( string $name , string $cacheConfig 'default' )
Restores configuration data stored in the Cache into configure. Restored values will overwrite existing ones.
$name $cacheConfig optional 'default' booleanstore( string $name , string $cacheConfig 'default' , array $data null )
Used to write runtime configuration into Cache. Stored runtime configuration can be restored using Configure::restore(). These methods can be used to enable configuration managers frontends, or other GUI type interfaces for configuration.
$name $cacheConfig optional 'default' $data optional null booleanversion( )
Used to determine the current version of CakePHP.
Usage Configure::version();
stringwrite( string|array $config , mixed $value null )
Used to store a dynamic variable in Configure.
Usage:
Configure::write('One.key1', 'value of the Configure::One[key1]'); Configure::write(array('One.key1' => 'value of the Configure::One[key1]')); Configure::write('One', array( 'key1' => 'value of the Configure::One[key1]', 'key2' => 'value of the Configure::One[key2]' ); Configure::write(array( 'One.key1' => 'value of the Configure::One[key1]', 'One.key2' => 'value of the Configure::One[key2]' ));
$config $value optional null boolean
© 2005–2016 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.
http://api.cakephp.org/2.7/class-Configure.html