Quick links: Content - sections - sub sections
EN FR

Modules are grouped in one or several directories called modules group, or repository of modules.

Declaring a modules group

Module groups are declared with jApp or into the composer.json file if you installed Jelix with Composer. (In Jelix 1.6 and lower, it was into the configuration, in the properties modulesPath).

An example with jApp in the application.init.php file:


   jApp::declareModulesDir(__DIR__.'/modules/');

Here the directory modules/ is declared as a module repository.

Modules from this directory could be activated and installed in your application.

If you installed Jelix with Composer, you have an other solution: declare the directories into the composer.json file of your application. This solution is highly recommended also for Composer packages which provide modules for Jelix. Declare directories and modules into the composer.json of the package, and it will be automatically taken account.


{
   ...
   "extra" : {
      "jelix": {
         "modules-dir" : [
            "modules/",
         ]
      }
   }
}

Here it declares the modules/ directory that is in the same directory of the composer.json.

Note that modules directories provided with jelix are automatically declared.

Declaring a single module

Like for groups of modules, you can declare directly a module directory with jApp or into the composer.json file of the application or the composer.json file of the Composer package which provides the module.


   jApp::declareModule(__DIR__.'/my_module/');

or in a composer.json file:


{
   ...
   "extra" : {
      "jelix": {
         "modules" : [
            "my_module/",
         ]
      }
   }
}

An other possibility is to declare its path into the application configuration. It is done into the modules section, with a parameter *.path, for example:


[modules]
my_module.path = app:vendor/my_vendor_name/my_package/the_module

It eases migration from jelix 1.6.x and is useful to declare a module with a configuration script, which cannot add a line of code into application.init.php without risks.