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

NAME

CatalystX::Crudite::Manual::Cookbook - Miscellaneous recipes

Introduction

In all recipes, replace strings like MyApp, myapp and MYAPP with the appropriately cased versions of your actual web application name.

Using multiple configurations

Problem: You want to use several configurations, for example, for testing, staging and production environments.

Solution: Use the standard Catalyst::Plugin::ConfigLoader mechanisms.

Create a configuration file myapp_test.yaml:

    Model::DB:
        connect_info:
            dsn: "DBI:Pg:database=myapp_test;host=localhost"
            user: foobar
            password: foobar

and another file myapp_stage.yaml:

    Model::DB:
        connect_info:
            dsn: "DBI:Pg:database=myapp_stage;host=localhost"
            user: foobar
            password: foobar

And so on for each of your deployment environments. Now you can choose which configuration file to use by setting a special environment variable to the file name suffix:

    export MYAPP_CONFIG_LOCAL_SUFFIX=test
    export MYAPP_CONFIG_LOCAL_SUFFIX=stage

The configuration in these files overrides your global configuration that is stored in lib/MyApp.pm.