jelix/composer-module-setup

Plugin for Composer to declare Jelix modules automatically into a Jelix application

Installs: 1 970

Dependents: 1

Suggesters: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:composer-plugin

0.5.0 2019-05-22 09:15 UTC

README

A plugin for Composer to declare automatically jelix modules into a jelix application

For Jelix 1.6.9 and higher.

Author who provide their modules via Composer, should declare directories containing modules or plugins. It will avoid the developer to declare them into his application.init.php (Jelix 1.7) or in the configuration (Jelix 1.6.9+).

installation

In the composer.json of your application, declare the plugin

{
    "require": {
        "jelix/composer-module-setup": "^0.5.0"
    }
}

Declaring modules and plugins into a package

Author who provide their modules via Composer, should declare directories containing modules or plugins. It will avoid the developer to declare them into his application.init.php.

To declare them, he should add informations into the extra/jelix object in composer.json:

{
    "extra": {
        "jelix": {
        }
    }
}

In this object, he can add three type of informations:

  • modules-dir, an array containing directories where modules can be found. These paths will be added to the jelix configuration parameter modulesPath.
  • plugins-dir, an array containing directories where plugins can be found. These paths will be added to the jelix configuration parameter pluginsPath.
  • modules, an array containing modules directories. These paths will be added into the modules section of the jelix configuration as <module>.path=<path>.

For instances, in the repository, if modules are in a "modules/" directory, the author should add these informations into his composer.json:

{
    "extra": {
        "jelix": {
            "modules-dir" : [
                "modules/"
            ],
            "plugins-dir" : [
                "plugins/"
            ],
            "modules" : [
                "mymoduleaaa/",
                "mymodulebbb/"
            ]
        }
    }
}

Declaring modules and plugins at the application level

Application developers could declare also their modules and plugins in the same way, in the composer.json of the application:

{
    "require": {
        "jelix/composer-module-setup": "^0.5.0"
    },
    "extra": {
        "jelix": {
            "modules-dir" : [
                "myapp/modules/"
            ],
            "plugins-dir" : [
                "myapp/plugins/"
            ],
            "modules" : [
                 "mainmodule/"
            ]
        }
    }
}

In Jelix 1.7 and higher

In your application.init.php, you should include the jelix_app_path.php:

<?php

require (__DIR__.'/vendor/autoload.php');

jApp::initPaths(
    __DIR__.'/'
    //__DIR__.'/www/',
    //__DIR__.'/var/',
    //__DIR__.'/var/log/',
    //__DIR__.'/var/config/',
    //__DIR__.'/scripts/'
);
jApp::setTempBasePath(realpath(__DIR__.'/temp').'/');

require (__DIR__.'/vendor/jelix_app_path.php');

Remember: in Jelix 1.7 and higher, declaring modules and plugins in the modulesPath/pluginsPath parameter in the configuration file is not supported anymore.

In Jelix 1.6.x equal or higher than 1.6.9

The composer plugin declares automatically modules and plugins directory into the localconfig.ini.php file, in modulesPath and pluginsPath properties, and also in the modules section.

However, at the application level, the composer.json should also content the path to the application directory (the directory containing the project.xml etc), and the path to the var/config directory, if the directory containing the composer.json file is not the application directory and/or if the var/config is not in the application directory. You must set these path into app-dir and var-config-dir (may be related to the composer.json directory)

{
    "require": {
        "jelix/composer-module-setup": "^0.5.0"
    },
    "extra": {
        "jelix": {
            "app-dir" : "myapp/",
            "var-config-dir" : "/var/lib/myapp/config/",
            "modules-dir" : []
        }
    }
}