Quick links: Content - sections - sub sections
EN FR
The page corresponding to the latest stable release can be seen in the Jelix 1.6 Manual

A module is a directory in which there are classes and files related to a domain. This files are organised in a precise file-system hierarchy as indicated below.

Creating a module

It's as simple as creating a sub-directory of a modules group, and filling it with controllers, persistent objects ...

Of course the module group should have been created and declared.

The module:create command helps you to create all directories of a module, and it activates and installs automatically the new module:


php dev.php module:create mymodule

This command creates the module "mymodule" in your application's sub-directory modules. It creates also some sub-directories as well as a default controller.

Important: The name of modules are used in the name of some classes generated automatically by Jelix. So you mustn't use other characters than a-z, A-Z, 0-9 and _.

By default, the module is created in the modules/ directory of the application. Perhaps you would like to create it into an other modules group. In this case, indicate the path of the repository after the module name.

This example creates a "supermodule" module into the shared-modules/ directory which is itself into the lib directory provided with jelix.


php dev.php module:create supermodule ../lib/shared-modules/

See the online help of the module:create command to know other options.

Setting the version and dependencies

After creating the module, you should verify if the default initial version is ok for you (0.1), and set dependencies. It is very important for the installation system of Jelix.

You can indicate the version to the module:create command, with the --ver option:


php dev.php module:create --ver 1.0 supermodule

You can also modify the version in the module.xml file generated in the module, if needed.

You can set dependencies of the module. Dependencies are modules necessary to execute the new module. In the <dependencies> element in the module.xml file, add a <module> element for each required module.


   <dependencies>
     <jelix minversion="1.6.0" maxversion="1.6.*" />
     <module name="jauth" minversion="1.2" />
     <module name="anOtherModule" minversion="1.0" maxversion="1.4.*" />
   </dependencies>

The attributes minversion and maxversion are optional.

For more details about the content of module.xml, read the corresponding chapter.

Directories inside a module

A module is a directory having at least one file, module.xml, containing some informations about the module: version, dependencies...

And you have some sub-directories, depending of what the module provides, and each containing specific files:

controllers/
controllers, corresponding to some URL
classes/
business classes, librairies, listeners for events etc.
templates/
file containing the content to send to browsers
responses/
response object that the module can provide for the whole application
locales/
properties files to localize templates or content generated by controllers
zones/
classes generating some part of a web page
daos/
files declaring mapping to a database
forms/
file declaring forms
install/
scripts to install or to upgrade the module
Commands/
commands for console.php
scripts/
scripts for the command line (deprecated)
plugins/
plugins for various components (jDb, jTpl...)
www/
CSS, JS, images files. There are accessible from a browser, by calling a specific controller of the "jelix" module
tests/
files doing unit tests for PHPUnit