The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Catalyst::Plugin::ConfigLoader - Load config files of various types

SYNOPSIS

    package MyApp;
    
    # ConfigLoader should be first in your list so
    # other plugins can get the config information
    use Catalyst qw( ConfigLoader ... );
    
    # by default myapp.* will be loaded
    # you can specify a file if you'd like
    __PACKAGE__->config( file => 'config.yaml' );    

DESCRIPTION

This module will attempt to load find and load a configuration file of various types. Currently it supports YAML, JSON, XML, INI and Perl formats.

To support the distinction between development and production environments, this module will also attemp to load a local config (e.g. myapp_local.yaml) which will override any duplicate settings.

METHODS

setup( )

This method is automatically called by Catalyst's setup routine. It will attempt to use each plugin and, once a file has been successfully loaded, set the config() section.

finalize_config

This method is called after the config file is loaded. It can be used to implement tuning of config values that can only be done at runtime. If you need to do this to properly configure any plugins, it's important to load ConfigLoader before them. ConfigLoader provides a default finalize_config method which walks through the loaded config hash and replaces any strings beginning containing __HOME__ with the full path to app's home directory (i.e. $c->path_to('') ). You can also use __path_to(foo/bar)__ which translates to $c->path_to('foo', 'bar')

get_config_path

This method determines the path, filename prefix and file extension to be used for config loading. It returns the path (up to the filename less the extension) to check and the specific extension to use (if it was specified).

The order of preference is specified as:

  • $ENV{ MYAPP_CONFIG }

  • $c->config->{ file }

  • $c->path_to( $application_prefix )

If either of the first two user-specified options are directories, the application prefix will be added on to the end of the path.

get_config_local_suffix

Determines the suffix of files used to override the main config. By default this value is local, but it can be specified in the following order of preference:

  • $ENV{ CATALYST_CONFIG_LOCAL_SUFFIX }

  • $ENV{ MYAPP_CONFIG_LOCAL_SUFFIX }

  • $c->config->{ config_local_suffix }

AUTHOR

  • Brian Cassidy <bricas@cpan.org>

CONTRIBUTORS

The following people have generously donated their time to the development of this module:

  • David Kamholz <dkamholz@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2006 by Brian Cassidy

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

SEE ALSO