Chapter: Dive into configuration
« Developping plugins | ^ Advanced development | Useful global objects » |
− Table of content
URL entry points ¶
An entry point is a script which manage some or all your application actions. Only entry points should be web accessible and therefore should lie in www/
directory of your application.
An entry point create a jCoordinator
object, a jRequest
object (to parse all request parameters) and indicates which configuration file to use.
Below is an example of an entry point script :
// application initialisation file
require_once ('../../testapp/application.init.php');
// configuration file
$config_file = 'index/config.ini.php';
// jCoordinator object
$jelix = new jCoordinator($config_file);
// jRequest object
require_once (JELIX_LIB_CORE_PATH.'request/jClassicRequest.class.php');
$request = new jClassicRequest();
// action processing
$jelix->process($request);
Theorically, an application should have one entry point per response type : classic, XML-RPC, JSON-RPC, RSS, Atom, and so on.. As a result, each entry point should also have its specific configuration file.
project.xml ¶
The file project.xml
contains some informations on the application. Some of these are important because they are used by the installer.
It is an XML file with a <project>
as root element, and which contains 4 elements:
<project xmlns="http://jelix.org/ns/project/1.0">
<info id="testapp@jelix.org" name="testapp" createdate="2005-01-01">
...
</info>
<dependencies>
...
</dependencies>
<directories>
...
</directories>
<entrypoints>
...
</entrypoints>
</project>
info ¶
Int the element info
, there are some informations indicative only about the application, like its name, a description, the copyright, the creator name etc. Note that this element can be used also in module.xml
files to identify a module. Here is an example:
<info id="testapp@jelix.org" name="testapp" createdate="2005-01-01">
<version>1.0</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-2010 Laurent Jouanneau and other contributors</copyright>
<creator name="Laurent Jouanneau" email="laurent@jelix.org" active="true" />
<contributor name="Superman" email="superman@superville.com" active="true" since="" role=""/>
<homepageURL>http://jelix.org</homepageURL>
</info>
Only the <version>
element and attributes id
and name
on <info>
are required. Others are optionals.
The id attribute should be a unique identifiant. That's why it is recommanded to use an email as an identifiant (or a UUID but it is less readable).
The attribute name
shoudl be a "technical" name (the name of the directory of the application or of the module for instance). The label
element can contain a displayable name.
dependencies ¶
The element <directories>
should contain informations about dependencies of the application. For the moment, only the jelix version is required.
<dependencies>
<jelix minversion="1.2.0" maxversion="1.2.*" />
</dependencies>
This element can be used in a module.xml
file, and can contain additionnaly one or more <module>
elements, which indicate modules that the installer should install in order to execute correctly the modules.
<module name="testurls" minversion="2.2" maxversion="2.3" />
<module name="jauthdb" />
<module name="jacl2db" />
directories ¶
This element indicate paths of some directories. all elements in this example are required:
<directories>
<config>var/config</config>
<log>var/log</log>
<var>var</var>
<www>www</www>
<temp>../temp/testapp</temp>
</directories>
entrypoints ¶
The entrypoints
element list all entry points of the application (in www/
or scripts/
), with their configuration file and their type.
<entrypoints>
<entry file="index.php" config="index/config.ini.php" />
<entry file="soap.php" config="soap/config.ini.php" type="soap"/>
<entry file="jsonrpc.php" config="jsonrpc/config.ini.php" type="jsonrpc"/>
<entry file="cmdline.php" config="cmdline/config.ini.php" type="cmdline"/>
</entrypoints>
module.xml ¶
A module.xml
file must be present in each directory of modules. It contains a root element module
which should contain a <info>
element and <dependencies>
element. See above to know how to write these elements.
<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.2" maxversion="1.2.*" />
<module name="testurls" minversion="1.0.2" maxversion="1.1b1" />
<module name="jauthdb" />
<module name="jacl2db" />
<module name="jacldb" />
</dependencies>
</module>
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 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 : 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 defaultconfig.ini.php
.
a glimpse at defaultconfig.ini.php
(abstract) :
locale = "fr_FR"
charset = "ISO-8859-1"
timeZone = "Europe/Paris"
theme = default
pluginsPath = lib:jelix-plugins/,app:plugins/
modulesPath = lib:jelix-modules/,app:modules/
dbProfils = dbprofils.ini.php
[modules]
mymodule=2
jauth=2
[coordplugins]
;nom = nom_fichier_ini
[responses]
...
Example : a classic request with index.php as entry point should define 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, var/config
would quickly become a mess).
A specific config should only define or redefine a small amount of properties:
startModule = "testapp"
startAction = "main:index"
[coordplugins]
autolocale = index/autolocale.ini.php
[responses]
html=myHtmlResponse
take xmlrpc.php entry point, its config file could be :
startModule = "testapp"
startAction = "xmlrpc:index"
And so on for others entry points.
Content of configuration file ¶
See lib/jelix/core/defaultconfig.ini.php
for the whole list of parameters. This file is the "source" of the identically-named file you find in var/config
of your application.
Below is a tour of all configuration sections.
generic section ¶
Usually its parameters are at the beginning of file. They define default or global values of the framework.
startModule = "jelix"
startAction = "default:index"
locale = "en_US"
charset = "UTF-8"
timeZone = "US/Pacific"
pluginsPath = lib:jelix-plugins/,app:plugins/
modulesPath = lib:jelix-modules/,app:modules/
dbProfils = dbprofils.ini.php
theme = default
use_error_handler = on
Parameters in details :
- startModule, startAction : default module and action (generally re-defined for each response type. see preceding section)
- locale, charset : default language and encoding of responses
- timeZone : set the time zone for every date and time functions
- pluginsPath : path list to plugins. learn more in plugins documentation.
- dbProfils : Database profiles configuration file. See database access.
- theme : default selected theme. Read theme system description.
- use_error_handler : this option shoud stay on for Jelix to return useful and detailed errors or exceptions.
modules section ¶
Contains the list of all used modules, and their access level
- 0 means the module is not used and must not be installed
- 1 means the module is used, but only by other modules (its daos, forms etc), but is not accessible directly from the web (so it has no controllers or existing controllers will never be called)
- 2 means the module is installed and usuable normally.
coordplugins section ¶
List all coordinator plugins Jelix has to activate. They will be loaded from the list of path defined by the pluginsPath option.
The example below demonstrates the activation of an authentication plugin. Its own set of options are defined in auth.coord.ini.php
file. Learn more about authentication.
[coordplugins]
;plugin name = ini filename
auth = "auth.coord.ini.php"
responses section ¶
this section allows to customize each response type and its alias. each line consists of a couple <response alias>=<response class>.
As for example, it is usual to overload html default response (jResponseHtml) by such a line : html=myhtmlresponse. Find more details in customizing common response
Below are the default alias and response types:
[responses]
html = jResponseHtml
redirect = jResponseRedirect
redirectUrl = jResponseRedirectUrl
binary = jResponseBinary
text = jResponseText
jsonrpc = jResponseJsonrpc
json = jResponseJson
xmlrpc = jResponseXmlrpc
xul = jResponseXul
xuloverlay = jResponseXulOverlay
xuldialog = jResponseXulDialog
xulpage = jResponseXulPage
rdf = jResponseRdf
xml = jResponseXml
zip = jResponseZip
rss2.0 = jResponseRss20
atom1.0 = jResponseAtom10
css= jResponseCss
ltx2pdf= jResponseLatexToPdf
tcpdf = jResponseTcpdf
error_handling section ¶
Those parameters are used to configure notifications occuring during an application script execution. Details can be found in error manager documentation.
Notifications have different levels. Jelix defined levels corresponding to PHP error_reporting levels:
- default = selected level if no other level corresponds
- error = notify an error stopping a script execution
- warning = notifu an error which doesn't stop a script
- notice = notify a possible error
- deprecated = notify a deprecated function (php 5.3)
- strict = notify core PHP messages about compatibility and interoperability
Below are the whole list of parameters:
[error_handling]
messageLogFormat = "%date%\t%ip\t[%code%]\t%msg%\t%file%\t%line%\n"
logFile = error.log
email = root@localhost
emailHeaders = "Content-Type: text/plain; charset=UTF-8\nFrom: webmaster@yoursite.com\nX-Mailer: Jelix\nX-Priority: 1 (Highest)\n"
quietMessage="A technical error has occured. Sorry for this trouble."
showInFirebug = off
; keywords you can use : ECHO, ECHOQUIET, EXIT, LOGFILE, SYSLOG, MAIL, TRACE
default = ECHO EXIT
error = ECHO EXIT
warning = ECHO
notice = ECHO
deprecated = ECHO
strict = ECHO
; exceptions implicitly use EXIT
exception = ECHO
- messageLogFormat and logFile configure a log file output (LOGFILE or SYSLOG)
- email et emailHeaders configure mail ouptut (MAIL)
- quietMessage defines a neutral message for user (ECHOQUIET)
- showInFirebug : if on, all notifications will be redirected to firebug extension of firefox browser using its console api.
The last set of options allows to associate ouptut formats to each level of notification. Each level can have more than one output format. For example, in production, you'll probably want to set :error = ECHOQUIET EXIT LOGFILE and so on.
compilation section ¶
Defines the template behavior of Jelix template engine. And more precisely of its compilation step. Find in-depth details in templates.
[compilation]
checkCacheFiletime = on
force = off
- checkCacheFiletime : if on template will be compiled if its file modification date is more recent than its already PHP compiled file.
- force : if on, template is systematically compiled
section zone ¶
There is an option to globally disable zone caching. It is useful during development environment but should be set to off in production.
To disable zone caching :
[zones]
disableCache = on // default to off
urlengine section ¶
@TODO : to complete
logfiles section ¶
This section defines how log calls through jLog api will be output.
Log files are created and stored in var/log/
application folder.
A per-module log file can be defined by setting a couple <module name>=<log filename>
and calling jLog methods with <module name> as last argument.
; default log
default = messages.log
; log for "news" module
news = news.log
Another example shows how you can use firebug extension as a log output (useful for quickly debugging). Still you can log to a classic file calling jLog methods with file as last argument (for dumping huge content for example).
[logfiles]
default="!firebug"
file = "messages.log"
Learn more about Jelix debugging through jLog documentation.
mailer section ¶
Parameters required to send mails through application scripts. As for example, authentication or notifications can send emails.
[mailer]
webmasterEmail = root@localhost
webmasterName =
; How to send mail : "mail" (mail()), "sendmail" (call sendmail), or "smtp" (send directly to a smtp)
mailerType = mail
; Sets the hostname to use in Message-Id and Received headers
; and as default HELO string. If empty, the value returned
; by SERVER_NAME is used or 'localhost.localdomain'.
hostname =
sendmailPath = "/usr/sbin/sendmail"
; if mailer = smtp , fill the following parameters
; SMTP hosts. All hosts must be separated by a semicolon : "smtp1.example.com:25;smtp2.example.com"
smtpHost = "localhost"
; default SMTP server port
smtpPort = 25
; SMTP HELO of the message (Default is hostname)
smtpHelo =
; SMTP authentication
smtpAuth = off
smtpUsername =
smtpPassword =
; SMTP server timeout in seconds
smtpTimeout = 10
acl section ¶
Defines options of access control list (ACL) or rights management. See rights management. You can use jAcl ou jAcl2, but not both at the same time. Indicate a driver to enable it.
[acl]
; example of driver : "db"
driver =
[acl2]
; example of driver : "db"
driver =
sessions section ¶
Determines how PHP sessions are stored (file or databse). Find more details in sessions documentation.
[sessions]
shared_session = off
; Use alternative storage engines for sessions
;
; usage :
;
; storage = "files"
; files_path = "app:var/sessions/"
;
; or
;
; storage = "dao"
; dao_selector = "jelix~jsession"
; dao_db_profile = ""