NAME

MPMinus::Configuration - Configuration of MPMinus

VERSION

Version 1.34

SYNOPSIS

package MPM::foo::Handlers;
use strict;

sub handler {
    my $r = shift;
    my $m = MPMinus->m;
    $m->conf_init($r, __PACKAGE__);
    ...
    my $project = $m->conf('project');
    ...
}

...or:

use MPMinus::Configuration;

my $config = new MPMinus::Configuration(
        config  => "foo.conf",
        confdir => "conf",
    );

DESCRIPTION

The module works with the configuration data of the resource on the platform mod_perl. The configuration data are relevant at the global level, and they are the same for all users at once!

new

my $config = new MPMinus::Configuration(
        r       => $r,
        config  => "/path/to/config/file.conf", # Or modperlroot relative, e.g, "file.conf"
        confdir => "/path/to/config/directory", # Or modperlroot relative, e.g, "conf"
        options => {... Config::General options ...},
    );

In case of non MPMinus context returns MPMinus::Configuration object

Example foo.conf file:

Foo     1
Bar     test
Flag    true

Example of the "conf" structure of $config object:

print Dumper($config->{conf});
$VAR1 = {
    'sid' => 'f4c11c107caa00d0',
    'modperlroot' => '/var/www/foo.localhost',
    'modperl_root' => '/var/www/foo.localhost',
    'hitime' => '1555517289.83407',
    'confdir' => '/var/www/foo.localhost/conf',
    'config' => '/var/www/foo.localhost/foo.conf',
    'foo' => 1
    'bar' => 'test',
    'flag' => 1,
}
config

Specifies absolute or relative path to config-file. If the value is not set then the value gets from dir_config() will be used - "Config"

confdir

Specifies absolute or relative path to config-dir. If the value is not set then the value gets from dir_config() will be used - "ConfDir"

options

Options of Config::General

r

Optional. Apache2::Request object

METHODS

config_error
my $error = $config->config_error;

Returns error string if occurred any errors while creating the object or reading the configuration file

conf_init
$m->conf_init( $r, $pkg );

NOTE! For MPMinus context only!

conf, get_conf, config, get_config, val

In MPMinus context:

my $value = $m->conf( 'key' );
my $config_hash = $m->config(); # Returns hash structure

In MPMinus::Configuration context:

my $value = $config->val( 'key' );
my $value = $config->conf( 'key' );
my $config_hash = $config->config(); # Returns hash structure

Gets value from config structure/object by key or config-hash

set_conf, set_config
$m->set_conf( 'key', "value" );
$config->set_conf( 'key', "value" );

Sets value to config structure/object by key

HISTORY

1.00 / 27.02.2008

Init version on base mod_main 1.00.0002

1.10 / 01.04.2008

Module is merged into the global module level

1.20 / 19.04.2010

Added new type (DSN) support: Oracle

1.30 / 08.01.2012

Added server_port variable

1.31 / Wed Apr 24 14:53:38 2013 MSK

General refactoring

1.32 / Wed May 8 12:25:30 2013 MSK

Added locked_keys parameter

See CHANGES file

DEPENDENCIES

mod_perl2, CTK, Config::General, Try::Tiny

TO DO

See TODO file

BUGS

* none noted

SEE ALSO

mod_perl2, CTK::Util, Config::General

AUTHOR

Serż Minus (Sergey Lepenkov) http://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See LICENSE file and https://dev.perl.org/licenses/