[ Index ]

PHP Cross Reference of Akelos Framework

title

Body

[close]

/ -> AkConfig.php (summary)

(no description)

Author: Arno Schneider
Copyright: Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org
License: GNU Lesser General Public License
File Size: 295 lines (10 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

AkConfig:: (13 methods):
  _generateCacheFileName()
  _useReadCache()
  _useWriteCache()
  _checkCacheValidity()
  _setCacheValidity()
  _readCache()
  _writeCache()
  _generateConfigFileName()
  _merge()
  _readConfig()
  _parseSettingsConstants()
  _getConstant()
  get()


Class: AkConfig  - X-Ref

Config Reader

Provides access to config files stored in:

AK_APP_DIR/config/*.yml

= Structure of a config file

A config file contains configuration directives for all
configured environments (development,testing,production).

A config file can have a default configuration section, which will
be the base for all other environments. That means if a default configuration
directive is not overwritten in an environment, the default directive is active.

Example:

<code>
default:
log:
file:   /tmp/debug.log
level:  verbose

development:
log:
file:   /tmp/development.log

testing:
log:
file:   /tmp/testing.log

production:
log:
file:   /tmp/production.log
level:  error
</code>

The above example sets a log level of "verbose" as the default.
The default log file is in "/tmp/debug.log".

The environments development and testing overwrite the default log file.

The production environment overwrites as well the log file and the log level.

The Log level for development will be "verbose" (inherited from default).
The log level for testing will be "verbose" (inherited from default).
The log level for production will be "error" (overwritten the default level).


= Accessing configuration files

The format of the config files is YAML.
The convention is that a yaml file in:

AK_APP_DIR/config/myconfig.yml

can be accessed via:

<code>
$config = new AkConfig();
$config->get('myconfig'); // loads myconfig.yml and section "AK_ENVIRONMENT"
</code>

By default the configuration for the environment defined in AK_ENVIRONMENT will be loaded.

By providing the desired environment in the get call you can change that:

<code>
$config = new AkConfig();
$config->get('myconfig','production'); // loads myconfig.yml and section production
</code>

= Config caching

The AkConfig class caches php representations of the yaml files inside:

AK_APP_DIR/config/cache/$environment/$config.yml

As soon as the modification time of a yaml-config file changes, the cache is invalidated
and will be regenerated.
_generateCacheFileName($namespace, $environment = AK_ENVIRONMENT)   X-Ref
No description

_useReadCache($environment = AK_ENVIRONMENT)   X-Ref
No description

_useWriteCache($environment = AK_ENVIRONMENT)   X-Ref
No description

_checkCacheValidity($namespace,$environment)   X-Ref
No description

_setCacheValidity($namespace, $environment)   X-Ref
No description

_readCache($namespace, $environment = AK_ENVIRONMENT, $force = false)   X-Ref
No description

_writeCache($config, $namespace, $environment = AK_ENVIRONMENT, $force = false)   X-Ref
No description

_generateConfigFileName($namespace,$environment = AK_ENVIRONMENT)   X-Ref
No description

_merge($default,$env)   X-Ref
No description

_readConfig($namespace, $environment = AK_ENVIRONMENT, $raise_error_if_config_file_not_found = true)   X-Ref
No description

_parseSettingsConstants($settingsStr)   X-Ref
No description

_getConstant($name)   X-Ref
No description

get($namespace, $environment = AK_ENVIRONMENT, $raise_error_if_config_file_not_found = true, $uncached = false)   X-Ref
No description



Generated: Mon Oct 27 12:43:49 2008 Cross-referenced by PHPXref 0.6