CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.4 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.4
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • App
  • CakePlugin
  • Configure
  • Object

Interfaces

  • ConfigReaderInterface

Class Configure

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.

Package: Cake\Core
Link: http://book.cakephp.org/2.0/en/development/configuration.html#configure-class
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Location: Cake/Core/Configure.php

Properties summary

  • $_readers protected static
    array
    Configured reader classes, used to load config files from resources
  • $_values protected static
    array
    Array of values currently stored in Configure.

Method Summary

  • _appDefaults() protected static
    Set app's default configs
  • _getReader() protected static

    Get the configured reader. Internally used by Configure::load() and Configure::dump() Will create new PhpReader for default if not configured yet.

  • _setErrorHandlers() protected static
    Set the error and exception handlers.
  • bootstrap() public static

    Initializes configure and runs the bootstrap process. Bootstrapping includes the following steps:

  • check() public static
    Returns true if given variable is set in Configure.
  • clear() public static
    Clear all values stored in Configure.
  • config() public static

    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.

  • configured() public static
    Gets the names of the configured reader objects.
  • delete() public static
    Used to delete a variable from Configure.
  • drop() public static

    Remove a configured reader. This will unset the reader and make any future attempts to use it cause an Exception.

  • dump() public static

    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.

  • load() public static

    Loads stored configuration information from a resource. You can add config file resource readers with Configure::config().

  • read() public static

    Used to read information stored in Configure. It's not possible to store null values in Configure.

  • restore() public static

    Restores configuration data stored in the Cache into configure. Restored values will overwrite existing ones.

  • store() public static

    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.

  • version() public static
    Used to determine the current version of CakePHP.
  • write() public static
    Used to store a dynamic variable in Configure.

Method Detail

_appDefaults() protected static ¶

_appDefaults( )

Set app's default configs

_getReader() protected static ¶

_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.

Parameters
string $config
The name of the configured adapter
Returns
mixed
Reader instance or false

_setErrorHandlers() protected static ¶

_setErrorHandlers( array $error , array $exception )

Set the error and exception handlers.

Parameters
array $error
The Error handling configuration.
array $exception
The exception handling configuration.

bootstrap() public static ¶

bootstrap( boolean $boot = true )

Initializes configure and runs the bootstrap process. Bootstrapping includes the following steps:

  • Setup App array in Configure.
  • Include app/Config/core.php.
  • Configure core cache configurations.
  • Load App cache files.
  • Include app/Config/bootstrap.php.
  • Setup error/exception handlers.
Parameters
boolean $boot optional true

check() public static ¶

check( string $var = null )

Returns true if given variable is set in Configure.

Parameters
string $var optional null
Variable name to check for
Returns
boolean
True if variable is there

clear() public static ¶

clear( )

Clear all values stored in Configure.

Returns
boolean
success.

config() public static ¶

config( 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());

Parameters
string $name

The name of the reader being configured. This alias is used later to read values from a specific reader.

ConfigReaderInterface $reader
The reader to append.

configured() public static ¶

configured( string $name = null )

Gets the names of the configured reader objects.

Parameters
string $name optional null
Returns
array
Array of the configured reader objects.

delete() public static ¶

delete( string $var = null )

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] }}}

Parameters
string $var optional null
the var to be deleted
Link
http://book.cakephp.org/2.0/en/development/configuration.html#Configure::delete

drop() public static ¶

drop( string $name )

Remove a configured reader. This will unset the reader and make any future attempts to use it cause an Exception.

Parameters
string $name
Name of the reader to drop.
Returns
boolean
Success

dump() public static ¶

dump( 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.

Usage

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');

Parameters
string $key

The identifier to create in the config adapter. This could be a filename or a cache key depending on the adapter being used.

string $config optional 'default'
The name of the configured adapter to dump data with.
array $keys optional array()

The name of the top-level keys you want to dump. This allows you save only some data stored in Configure.

Returns
boolean
success
Throws
ConfigureException
if the adapter does not implement a dump method.

load() public static ¶

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

Parameters
string $key
name of configuration resource to load.
string $config optional 'default'
Name of the configured reader to use to read the resource identified by $key.
boolean $merge optional true
if config files should be merged instead of simply overridden
Returns
mixed
false if file not found, void if load successful.
Throws
ConfigureException
Will throw any exceptions the reader raises.
Link
http://book.cakephp.org/2.0/en/development/configuration.html#Configure::load

read() public static ¶

read( string $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] }}}

Parameters
string $var optional null
Variable to obtain. Use '.' to access array elements.
Returns
mixed
value stored in configure, or null.
Link
http://book.cakephp.org/2.0/en/development/configuration.html#Configure::read

restore() public static ¶

restore( string $name , string $cacheConfig = 'default' )

Restores configuration data stored in the Cache into configure. Restored values will overwrite existing ones.

Parameters
string $name
Name of the stored config file to load.
string $cacheConfig optional 'default'
Name of the Cache configuration to read from.
Returns
boolean
Success.

store() public static ¶

store( 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.

Parameters
string $name
The storage name for the saved configuration.
string $cacheConfig optional 'default'
The cache configuration to save into. Defaults to 'default'
array $data optional null
Either an array of data to store, or leave empty to store all values.
Returns
boolean
Success

version() public static ¶

version( )

Used to determine the current version of CakePHP.

Usage Configure::version();

Returns
string
Current version of CakePHP

write() public static ¶

write( 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]' )); }}}

Parameters
string|array $config

The key to write, can be a dot notation value. Alternatively can be an array containing key(s) and value(s).

mixed $value optional null
Value to set for var
Returns
boolean
True if write was successful
Link
http://book.cakephp.org/2.0/en/development/configuration.html#Configure::write

Properties detail

$_readers ¶

protected static array

Configured reader classes, used to load config files from resources

See
Configure::load()
array()

$_values ¶

protected static array

Array of values currently stored in Configure.

array(
    'debug' => 0
)
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs