The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Acme::Crux::Plugin::Config - The Acme::Crux plugin for configuration your application

SYNOPSIS

    # In startup
    my $config = $app->plugin('Config');
    my $config = $app->plugin('Config', undef, {file => '/etc/myapp.conf'});

    # In application
    my $val = $app->config->get("/foo/bar/baz");
    my $all = $app->config->conf;

    my $array = $app->config->array('/foo'); # 'value'
        # ['value']

    my $hash = $app->config->hash('/foo'); # { foo => 'first', bar => 'second' }
        # { foo => 'first', bar => 'second' }

    my $first = $app->config->first('/foo'); # ['first', 'second', 'third']
        # first

    my $latest = $app->config->latest('/foo'); # ['first', 'second', 'third']
        # third

DESCRIPTION

The Acme::Crux plugin for configuration your application

OPTIONS

This plugin supports the following options

default

    $app->plugin(Config => undef, {default => {foo => 'bar'});

Sets the default configuration hash

Default: no defaults, empty config structure

dirs

    $app->plugin(Config => undef, {dirs => ['/etc/foo', '/etc/bar']});

Paths to additional directories of config files

Default: no additional directories

file

    $app->plugin(Config => undef, {file => '/etc/myapp.conf'});

Path to configuration file, absolute or relative to the application root directory, defaults to the value of the $moniker.conf in the application root directory.

Default: configfile command line option or configfile application argument or /etc/$moniker/$moniker.conf otherwise

noload

    $app->plugin(Config => undef, {noload => 1});

This option disables auto loading config file

Default: noload command line option or config_noload application argument or 0 otherwise

opts, options

    $app->plugin(Config => undef, {opts => {'-AutoTrue' => 0}});
    $app->plugin(Config => undef, {options => {'-AutoTrue' => 0}});

Sets the Config::General options directly

Default: no special options

root

    $app->plugin(Config => undef, {root => '/etc/myapp'});

Sets the root directory to configuration files and directories location

Default: configroot command line option or root application argument or /etc/$moniker otherwise

METHODS

This class inherits all methods from Acme::Crux::Plugin and implements the following new ones

register

    $plugin->register($app, {file => '/etc/app.conf'});

Register plugin in Acme::Crux application and merge configuration

HELPERS

All helpers of this plugin are allows get access to configuration object. See Acrux::Config for details

config, conf

Returns Acrux::Config object

TO DO

See TODO file

SEE ALSO

Acme::Crux::Plugin, Acrux::Config

AUTHOR

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

COPYRIGHT

Copyright (C) 1998-2024 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/