4 Catalyst::Plugin::ConfigLoader::Manual - Guide to using the ConfigLoader plugin
10 use Catalyst qw( ConfigLoader ... );
12 =head1 ENVIRONMENT VARIABLES
16 =item * C<MYAPP_CONFIG> - specific config file to load for "MyApp"
18 =item * C<CATALYST_CONFIG_LOCAL_SUFFIX> - global suffix for extra config files
20 =item * C<MYAPP_CONFIG_LOCAL_SUFFIX> - suffix specifically for "MyApp"
26 =head2 Config::General
41 <Component Controller::Foo>
104 =head3 Example Config
108 'Controller::Foo' => {
126 =head3 Example Config
129 <name>MyApp::CMS</name>
131 <upload_dir>/var/www/docs/myapp-cms/uploads</upload_dir>
134 <connect_info>dbi:mysql:cmsdb</connect_info>
135 <connect_info>user</connect_info>
136 <connect_info>password</connect_info>
138 <component name="View::TT">
139 <INCLUDE_PATH>__path_to(root,templates)__</INCLUDE_PATH>
140 <ENCODING>UTF-8</ENCODING>
142 <PRE_CHOMP>2</PRE_CHOMP>
143 <POST_CHOMP>2</POST_CHOMP>
148 Note that the name attribute for the C<model> tag should be the relative
149 namespace of the Catalyst model, not the absolute one. That is for
150 C<MyApp::Model::Something> the C<name> attribute should be C<Something>.
164 =head3 Example Config
175 =head2 Configuring a Catalyst::Model::DBIC::Schema model from a YAML config
178 schema_class: MyApp::MySchema
180 - dbi:SQLite:myapp.db
185 =head2 Converting your existing config to Config::General format
187 As of L<Catalyst::Devel> 1.07, a newly created application will use
188 L<Config::General> for configuration. If you wish to convert your existing
189 config, run the following one-liner (replacing MyApp with your app's name):
191 perl -Ilib -MMyApp -MConfig::General -e 'Config::General->new->save_file("myapp.conf", MyApp->config);'
193 =head2 Using UTF-8 strings in a Config::General file
195 If you have UTF-8 strings in your L<Config::General>-based config file, you
196 should add the following config information to MyApp.pm:
198 __PACKAGE__->config( 'Plugin::ConfigLoader' => {
200 'General' => { -UTF8 => 1 },
204 =head2 Using a local configuration file
206 When ConfigLoader reads configurations, it starts by reading the configuration
207 file for C<myapp> with one of the supported extensions as listed
208 L<above|/Config Formats>.
210 For example, A L<Config::General> config file is C<myapp.conf>.
212 If a configuration file called C<myapp_local> exists with one of the supported
213 file extensions, it will also be read, and values from that file will
214 override values from the main config file.
216 A L<Config::General> local configuration file would be called
219 The C<local> suffix can be changed. See
220 L<Catalyst::Plugin::ConfigLoader/get_config_local_suffix> for the details of
223 This is useful because it allows different people or environments to have
224 different configuration files. A project with three developers,
225 I<Tom>, I<Dick>, and I<Harry> as well as a production environment can have
226 a C<myapp_tom.conf>, a C<myapp_dick.conf>, a C<myapp_harry.conf>, and a
227 C<myapp_production.conf>.
229 Each developer, and the web server, would set the environment variable
230 to load their proper configuration file. All of the configurations can
231 be stored properly in source control.
233 If there is no C<myapp_local.ext> (where .ext is a supported extension), and
234 the individual configuration files contain something required to start the
235 application, such as the Model's data source definition, the applicaton won't
236 start unless the environment variable is set properly.