/
config.gtw
250 lines (187 loc) · 7.88 KB
/
config.gtw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
~~LANG:FR@frman:configuration~~
A Jelix application have several configuration files:
* A project.xml file, describing general information about the application
* A module.xml file in each module, describing general information about the module
* A defaultconfig.ini.php file for the global configuration, and a config.ini.php file for each entry points
* A profiles.ini.php for connections profiles (database configuration for example).
All are automatically generated when you create an application or a module.
However, you have to modify them to bring additionnal information or to change
parameters.
This chapter presents these files. See [[configuration-details|the chapter on configuration details]] to know more.
===== The project.xml file =====
The file @@F@project.xml@@ contains some informations on the application. Some
of these are important because they are used by the installer. Here is an
example:
<code xml>
<?xml version="1.0" encoding="iso-8859-1"?>
<project xmlns="http://jelix.org/ns/project/1.0">
<info id="testapp@jelix.org" name="testapp" createdate="2005-01-01">
<version>1.3</version>
<label lang="en-EN">Testapp</label>
<description lang="en-EN">Application to test Jelix</description>
<licence URL="http://www.gnu.org/licenses/gpl.html">GPL</licence>
<copyright>2005-2011 Laurent Jouanneau and other contributors</copyright>
<creator name="Laurent Jouanneau" email="laurent@jelix.org" active="true" />
<homepageURL>http://jelix.org</homepageURL>
</info>
<dependencies>
<jelix minversion="1.3" maxversion="1.3.*" />
</dependencies>
<directories>
<config>var/config</config>
<log>var/log</log>
<var>var</var>
<www>www</www>
<temp>../temp/testapp</temp>
</directories>
<entrypoints>
<entry file="index.php" config="index/config.ini.php" />
<entry file="soap.php" config="soap/config.ini.php" type="soap"/>
</entrypoints>
</project>
</code>
===== The module.xml file =====
A @@F@module.xml@@ file must be present in each directory of modules. It
describes some general information, and dependencies with other modules.
<code xml>
<module xmlns="http://jelix.org/ns/module/1.0">
<info id="jelix_tests@testapp.jelix.org" name="jelix_tests">
<version>1.0</version>
<label>Jelix tests</label>
<description>unit tests for jelix</description>
</info>
<dependencies>
<jelix minversion="1.3" maxversion="1.3.*" />
<module name="testurls" minversion="1.0.2" maxversion="1.1b1" />
<module name="jauthdb" />
<module name="jacl2db" />
<module name="jacldb" />
</dependencies>
</module>
</code>
===== Configuration ini files=====
Jelix framework configuration is stored in an //ini//-like file. It is a file
structured by sections (@@[section name]@@). Each section is a collection of
@@parameter-name=value@@ pairs. There is a generic section, un-named, usually at
the start of such file.
Configuration files are stored in @@F@var/config@@.
As said before, each entry point may have its specific config file. Although in
practice, many parameters can be shared between them. To prevent wasteful
repeats defines a common config file : @@F@defaultconfig.ini.php@@. Jelix
automatically read its entries in addition to each config file related to an
entry point. No need to tell jelix about it in an entry point.
Then, should lay in an entry point related config file, only specific parameters
or overloaded parameters already defined in @@F@defaultconfig.ini.php@@.
A glimpse at @@F@defaultconfig.ini.php@@ (abstract):
<code ini>
locale = "fr_FR"
charset = "ISO-8859-1"
timeZone = "Europe/Paris"
theme = default
pluginsPath = lib:jelix-plugins/,app:plugins/
modulesPath = lib:jelix-modules/,app:modules/
[modules]
mymodule=2
jauth=2
[coordplugins]
;nom = nom_fichier_ini
[responses]
...
</code>
Example: a classic request with index.php as entry point should define
@@F@var/config/index/config.ini.php@@ file. Storing under an //index//
sub-directory serves only a better organization (As each entry point may have
its config file, @@F@var/config@@ would quickly become a mess).
A specific config should only define or redefine a small amount of properties:
<code ini>
startModule = "testapp"
startAction = "main:index"
[coordplugins]
autolocale = index/autolocale.ini.php
[responses]
html=myHtmlResponse
</code>
take xmlrpc.php entry point, its config file could be :
<code ini>
startModule = "testapp"
startAction = "xmlrpc:index"
</code>
And so on for others entry points.
You have to know that a second @@F@defaultconfig.ini.php@@ exists into the
@@F@lib/jelix/core/@@ directory. It contains all possible parameters and some
comments. Jelix reads it first, then it read the @@F@defaultconfig.ini.php@@ of
your application, and then it reads the configuration file of the entry point.
Values of a configuration file override values of the previous configuration
file.
===== The profiles.ini.php file =====
This file contains all connections parameters of some Jelix Components: SQL and
NoSQL databases, SOAP web services, cache etc. In Jelix 1.2 and lower, these
parameters were stored in several files (dbProfils.ini.php, cache.ini.php...).
Since Jelix 1.3, all is stored in an unique file.
This is an ini file. Each section correspond to a profile. A profile is a set of
parameters of a single connection. Sections names are composed of two names,
separated by a ":":
* first name is the name of the connection type, (often corresponding to the composant name)
* second name is a name of your choice. However two names have a special
meaning: "default" indicates the default profile to use if the profile name
is not given to the component. And "__common__", described below.
The content of the section content connection parameters.
Here is an example for a jDb connection (jDb allow to access to a SQL database):
<code ini>
[jdb:default]
driver=mysqli
host=localhost
login= mylogin
password=mypassword
</code>
=== Profile Alias ===
You can define some profile alias, ie more than one name to a profile. This is
useful for example when a module uses a specific profile name, but it correspond
to an existing profile in your configuration.
Aliases are defined in a section whose name contains only the name of the
connection type. An example with jDb, defining the alias "jacl2_profile' for the
default profile:
<code ini>
[jdb]
jacl2_profile = default
[jdb:default]
driver=mysqli
host=localhost
login= mylogin
password=mypassword
</code>
An alias should not linked to an other alias.
=== Common parameters ===
It is possible to define parameters that are common to all profiles of the same
type. This avoids repeating them in each profile. To do this, you must declare
them in a special profile, @@__common__@@.
For example, if all connections to SQL databases (jDB) must be persistent and
are all on the same server:
<code ini>
[jdb:__common__]
host=my.server.example.com
persistant=on
</code>
You can of course redefine these parameters in profiles.
===== Virtual profile =====
You can use a profile which is not declared in @@F@profiles.ini.php@@ file. Then
you can use a connection whose informations is known only during the execution.
A virtual profile must be created before using your component. Use
@@M@createVirtualProfile@@ method of the object @@C@jProfiles@@ and pass it, the
type name of connection, a name and an array of parameters.
Example
<code php>
$params = array(
'driver'=>'mysqli',
'host'=>'localhost',
'database'=>'jelix',
'user'=>'toto',
'password'=>'blabla',
'persistent'=>false,
'force_encoding'=>true
);
jProfiles::createVirtualProfile('jdb', 'my_profil', $params);
$cnx = jDb::getConnection('my_profil');
// and play with your database
</code>
Of course, all parameters defined in a @@__common__@@ profile apply on virtual profiles.