<<

NAME

Koha::Config - Read Koha configuration file

SYNOPSIS

    use Koha::Config;

    my $config = Koha::Config->get_instance;
    my $database = $config->get('database');
    my $serverinfo = $config->get('biblioserver', 'serverinfo');

    my $otherconfig = Koha::Config->get_instance('/path/to/other/koha-conf.xml');

DESCRIPTION

Koha::Config is a helper module for reading configuration variables from the main Koha configuration file ($KOHA_CONF)

CLASS METHODS

get_instance

    $config = Koha::Config->get_instance;
    $config = Koha::Config->get_instance($file);

Reads $file and returns the corresponding Koha::Config object.

If $file is not given (or undef) it defaults to the result of Koha::Config->guess_koha_conf.

Multiple calls with the same arguments will return the same object, and the file will be read only the first time.

read_from_file

    $config = Koha::Config->read_from_file($file);

Reads $file and returns the corresponding Koha::Config object.

Unlike get_instance, this method will read the file at every call, so use it carefully. In most cases, you should use get_instance instead.

guess_koha_conf

    $file = Koha::Config->guess_koha_conf;

Returns the path to Koha main configuration file.

Koha's main configuration file koha-conf.xml is searched for according to this priority list:

1. Path supplied via use C4::Context '/path/to/koha-conf.xml'
2. Path supplied in KOHA_CONF environment variable.
3. Path supplied in INSTALLED_CONFIG_FNAME, as long as value has changed from its default of '__KOHA_CONF_DIR__/koha-conf.xml', as happens when Koha is installed in 'standard' or 'single' mode.
4. Path supplied in CONFIG_FNAME.

The first entry that refers to a readable file is used.

INSTANCE METHODS

get

    $value = $config->get($key);
    $value = $config->get($key, $section);

Returns the configuration entry corresponding to $key and $section. The returned value can be a string, an arrayref or a hashref. If $key is not found, it returns undef.

$section can be one of 'listen', 'server', 'serverinfo', 'config'. If not given, $section defaults to 'config'.

timezone

  $timezone = $config->timezone

  Returns the configured timezone. If not configured or invalid, it returns
  'local'.

<<