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
118        </config>
119
120       Note that the name attribute for the "model" tag should be the relative
121       namespace of the Catalyst model, not the absolute one.  That is for
122       "MyApp::Model::Something" the "name" attribute should be "Something".
123
124   YAML
125       Extensions
126
127       ·   yml
128
129       ·   yaml
130
131       Example Config
132
133           ---
134           name: TestApp
135           Controller::Foo:
136               foo: bar
137           Model::Baz:
138               qux: xyzzy
139

COOKBOOK

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