1Catalyst::Plugin::ConfiUgsLeoradCeorn:t:rMiabnuutaeldC(a3Pt)earllysDto:c:uPmleungtiant:i:oCnonfigLoader::Manual(3)
2
3
4

NAME

6       Catalyst::Plugin::ConfigLoader::Manual - Guide to using the
7       ConfigLoader plugin
8

BASIC USAGE

10           package MyApp;
11
12           use Catalyst qw( ConfigLoader ... );
13

ENVIRONMENT VARIABLES

15       •   "MYAPP_CONFIG" - specific config file to load for "MyApp"
16
17       •   "CATALYST_CONFIG_LOCAL_SUFFIX" - global suffix for extra config
18           files
19
20       •   "MYAPP_CONFIG_LOCAL_SUFFIX" - suffix specifically for "MyApp"
21

CONFIG FORMATS

23   Config::General
24       Extensions
25
26       •   cnf
27
28       •   conf
29
30       Example Config
31
32           name = TestApp
33           <Component Controller::Foo>
34               foo bar
35           </Component>
36           <Model Baz>
37               qux xyzzy
38           </Model>
39
40   INI
41       Extensions
42
43       •   ini
44
45       Example Config
46
47           name=TestApp
48
49           [Controller::Foo]
50           foo=bar
51
52           [Model::Baz]
53           qux=xyzzy
54
55   JSON
56       Extensions
57
58       •   jsn
59
60       •   json
61
62       Example Config
63
64           {
65               "name": "TestApp",
66               "Controller::Foo": {
67                   "foo": "bar"
68               },
69               "Model::Baz": {
70                   "qux": "xyzzy"
71               }
72           }
73
74   Perl
75       Extensions
76
77       •   pl
78
79       •   perl
80
81       Example Config
82
83           {
84               name => 'TestApp',
85               'Controller::Foo' => {
86                   foo => 'bar'
87               },
88               'Model::Baz' => {
89                   qux => 'xyzzy'
90               }
91           }
92
93   XML
94       Extensions
95
96       •   xml
97
98       Example Config
99
100           <config>
101               <name>MyApp::CMS</name>
102               <paths>
103                   <upload_dir>/var/www/docs/myapp-cms/uploads</upload_dir>
104               </paths>
105               <model name="DB">
106                   <connect_info>dbi:mysql:cmsdb</connect_info>
107                   <connect_info>user</connect_info>
108                   <connect_info>password</connect_info>
109               </model>
110               <component name="View::TT">
111                   <INCLUDE_PATH>__path_to(root,templates)__</INCLUDE_PATH>
112                   <ENCODING>UTF-8</ENCODING>
113                   <TRIM>1</TRIM>
114                   <PRE_CHOMP>2</PRE_CHOMP>
115                   <POST_CHOMP>2</POST_CHOMP>
116               </component>
117           </config>
118
119       Note that the name attribute for the "model" tag should be the relative
120       namespace of the Catalyst model, not the absolute one.  That is for
121       "MyApp::Model::Something" the "name" attribute should be "Something".
122
123   YAML
124       Extensions
125
126       •   yml
127
128       •   yaml
129
130       Example Config
131
132           ---
133           name: TestApp
134           Controller::Foo:
135               foo: bar
136           Model::Baz:
137               qux: xyzzy
138

COOKBOOK

140   Configuring a Catalyst::Model::DBIC::Schema model from a YAML config
141           Model::MyModel:
142               schema_class: MyApp::MySchema
143               connect_info:
144                   - dbi:SQLite:myapp.db
145                   - ''
146                   - ''
147                   - AutoCommit: 1
148
149   Converting your existing config to Config::General format
150       As of Catalyst::Devel 1.07, a newly created application will use
151       Config::General for configuration. If you wish to convert your existing
152       config, run the following one-liner (replacing MyApp with your app's
153       name):
154
155           perl -Ilib -MMyApp -MConfig::General -e 'Config::General->new->save_file("myapp.conf", MyApp->config);'
156
157   Using UTF-8 strings in a Config::General file
158       If you have UTF-8 strings in your Config::General-based config file,
159       you should add the following config information to MyApp.pm:
160
161           __PACKAGE__->config( 'Plugin::ConfigLoader' => {
162               driver => {
163                   'General' => { -UTF8 => 1 },
164               }
165           } );
166
167   Using a local configuration file
168       When ConfigLoader reads configurations, it starts by reading the
169       configuration file for "myapp" with one of the supported extensions as
170       listed above.
171
172       For example, A Config::General config file is myapp.conf.
173
174       If a configuration file called "myapp_local" exists with one of the
175       supported file extensions, it will also be read, and values from that
176       file will override values from the main config file.
177
178       A Config::General local configuration file would be called
179       myapp_local.conf.
180
181       The "local" suffix can be changed.  See "get_config_local_suffix" in
182       Catalyst::Plugin::ConfigLoader for the details of how.
183
184       This is useful because it allows different people or environments to
185       have different configuration files.  A project with three developers,
186       Tom, Dick, and Harry as well as a production environment can have a
187       myapp_tom.conf, a myapp_dick.conf, a myapp_harry.conf, and a
188       myapp_production.conf.
189
190       Each developer, and the web server, would set the environment variable
191       to load their proper configuration file.  All of the configurations can
192       be stored properly in source control.
193
194       If there is no myapp_local.ext (where ".ext" is a supported extension),
195       and the individual configuration files contain something required to
196       start the application, such as the Model's data source definition, the
197       applicaton won't start unless the environment variable is set properly.
198
199
200
201perl v5.38.0                      2023C-a0t7a-l2y0st::Plugin::ConfigLoader::Manual(3)
Impressum