Méthodes de la classe Configure
Use write() to store data in the application’s configuration.
<?php
Configure::write('Company.name','Pizza, Inc.');
Configure::write('Company.slogan','Pizza for your body and soul');
?>
<?phpConfigure::write('Company.name','Pizza, Inc.');Configure::write('Company.slogan','Pizza for your body and soul');?>
Note the usage of dot notation in the $key parameter. You can use this notation to organize your configuration into logical groups.
The above example could also be written in a single call:
<?php
Configure::write(
'Company',array('name'=>'Pizza, Inc.','slogan'=>'Pizza for your body and soul')
);
?>
<?phpConfigure::write('Company',array('name'=>'Pizza, Inc.','slogan'=>'Pizza for your body and soul'));?>
You can use Configure::write(‘debug’, $int) to switch between debug and production modes on the fly. This is especially handy for AMF or SOAP interactions where debugging information can cause parsing problems.
Used to read configuration data from the application. Defaults to CakePHP’s important debug value. If a key is supplied, the data is returned. Using our examples from write() above, we can read that data back:
<?php
Configure::read('Company.name'); //yields: 'Pizza, Inc.'
Configure::read('Company.slogan'); //yields: 'Pizza for your body and soul'
Configure::read('Company');
//yields:
array('name' => 'Pizza, Inc.', 'slogan' => 'Pizza for your body and soul');
?>
<?phpConfigure::read('Company.name'); //yields: 'Pizza, Inc.'Configure::read('Company.slogan'); //yields: 'Pizza for your body and soul'Configure::read('Company');//yields:array('name' => 'Pizza, Inc.', 'slogan' => 'Pizza for your body and soul');?>
Used to delete information from the application’s configuration.
<?php Configure::delete('Company.name'); ?>
<?php Configure::delete('Company.name'); ?>
Use this method to load configuration information from a specific file.
/app/config/messages.php:
<?php
$config['Company']['name'] = 'Pizza, Inc.';
$config['Company']['slogan'] = 'Pizza for your body and soul';
$config['Company']['phone'] = '555-55-55';
?>
<?php
Configure::load('messages');
Configure::read('Company.name');
?>
/app/config/messages.php:<?php$config['Company']['name'] = 'Pizza, Inc.';$config['Company']['slogan'] = 'Pizza for your body and soul';$config['Company']['phone'] = '555-55-55';?><?phpConfigure::load('messages');Configure::read('Company.name');?>
Note that every configure key-value pair is represented in the file with the $configure array. Any other variables in the file will be ignored by the load() function.
Returns the CakePHP version for the current application.
write
write(string $key, mixed $value)
write(string $key, mixed $value)
Use write() to store data in the application’s configuration.
Configure::write('Company.name','Pizza, Inc.');
Configure::write('Company.slogan','Pizza for your body and soul');
Configure::write('Company.name','Pizza, Inc.');Configure::write('Company.slogan','Pizza for your body and soul');
Note the usage of dot notation in the $key parameter. You can use this notation to organize your configuration into logical groups.
The above example could also be written in a single call:
Configure::write(
'Company',array('name'=>'Pizza, Inc.','slogan'=>'Pizza for your body and soul')
);
Configure::write('Company',array('name'=>'Pizza, Inc.','slogan'=>'Pizza for your body and soul'));
You can use Configure::write(‘debug’, $int) to switch between debug and production modes on the fly. This is especially handy for AMF or SOAP interactions where debugging information can cause parsing problems.
read
read(string $key = 'debug')
read(string $key = 'debug')
Used to read configuration data from the application. Defaults to CakePHP’s important debug value. If a key is supplied, the data is returned. Using our examples from write() above, we can read that data back:
Configure::read('Company.name'); //yields: 'Pizza, Inc.'
Configure::read('Company.slogan'); //yields: 'Pizza for your body and soul'
Configure::read('Company');
//yields:
array('name' => 'Pizza, Inc.', 'slogan' => 'Pizza for your body and soul');
Configure::read('Company.name'); //yields: 'Pizza, Inc.'Configure::read('Company.slogan'); //yields: 'Pizza for your body and soul'Configure::read('Company');//yields:array('name' => 'Pizza, Inc.', 'slogan' => 'Pizza for your body and soul');
delete
delete(string $key)
delete(string $key)
Used to delete information from the application’s configuration.
Configure::delete('Company.name');
Configure::delete('Company.name');
load
load(string $path)
load(string $path)
Use this method to load configuration information from a specific file.
// /app/config/messages.php:
<?php
$config['Company']['name'] = 'Pizza, Inc.';
$config['Company']['slogan'] = 'Pizza for your body and soul';
$config['Company']['phone'] = '555-55-55';
?>
<?php
Configure::load('messages');
Configure::read('Company.name');
?>
// /app/config/messages.php:<?php$config['Company']['name'] = 'Pizza, Inc.';$config['Company']['slogan'] = 'Pizza for your body and soul';$config['Company']['phone'] = '555-55-55';?><?phpConfigure::load('messages');Configure::read('Company.name');?>
Note that every configure key-value pair is represented in the file with the $config array. Any other variables in the file will be ignored by the load() function.
version
version()
version()
Returns the CakePHP version for the current application.

login to add a comment