2017 © Pedro Peláez
 

composer-plugin composer-module-setup

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

image

jelix/composer-module-setup

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

  • Monday, September 26, 2016
  • by laurentj
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,387 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 7 % Grown

The README.md

composer-module-setup

A plugin for Composer to declare automatically jelix modules into a jelix application, (*1)

For Jelix 1.6.9 and higher., (*2)

Authors 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+)., (*3)

installation

In the composer.json of your application, declare the plugin and authorize the plugin to be executed by Composer., (*4)

{
    "require": {
        "jelix/composer-module-setup": "^1.0.0"
    },
    "config": {
        "allow-plugins": {
            "jelix/composer-module-setup": true
        }
    }
}

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., (*5)

To declare them, he should add information into the extra/jelix object in composer.json:, (*6)

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

In this object, he can add three type of information:, (*7)

  • 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 information into his composer.json:, (*8)

{
    "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:, (*9)

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

Enable modules on entrypoints automatically (jelix 1.6 only)

In module packages, you can indicate on which entrypoint the module should be enabled., (*10)

{
    "extra": {
        "jelix": {
            "autoconfig-access-16" : {
                "__any_app" : {
                    "<modulename>": {
                        "__global": 1
                    }
                },
                "app/identifiant1" : {
                    "<modulename>": {
                        "__global": 1,
                        "index" : 2,
                        "admin" : 1   
                    }
                }
            }
        }
    }
}

app/identifiant1 must be the application id that is indicated into the project.xml file ( id attribute of the <info> element)., (*11)

In the composer.json of the application, you can also indicate the same informations for each module, when a module does not provide an "autoconfig-access-16" configuration, (*12)

{
    "extra": {
        "jelix": {
            "modules-autoconfig-access-16" : {
                "package/name1" : {
                    "<modulename>": {
                        "__global": 1,
                        "index" : 2,
                        "admin" : 1   
                    }
                },
                "package/name2" : {
                    "<modulename>": {
                        "__global": 1,
                        "index" : 2,
                        "admin" : 1   
                    }
                }
            }
        }
    }
}

If the package has already an "autoconfig-access-16" configuration, this modules-autoconfig-access-16 configuration has priority over it., (*13)

Indicating the path to the app or the configuration directory

At the application level, the composer.json may content the path to the application directory (the directory containing the project.xml etc), and the path to the var/config directory., (*14)

It is useful when the directory containing the composer.json file is not the application directory and/or if the var/config is not in the application directory, (*15)

So you must set these paths into app-dir and var-config-dir. Path should be relative to the composer.json directory, or can be absolute., (*16)

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

In Jelix 1.7 and higher

In order to use modules declared into a composer.json file, you should include the jelix_app_path.php file into your application.init.php:, (*17)

<?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');

This jelix_app_path.php file is generated automatically by the composer-module-setup plugin., (*18)

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

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 or into the mainconfig.ini.php file, in modulesPath and pluginsPath properties, and also in the modules section., (*20)

You can also indicate if you want that the plugin modify localconfig.ini.php or mainconfig.ini.php. By default it is localconfig.ini.php. Indicate the configuration filename into config-file-16:, (*21)

{
    "require": {
        "jelix/composer-module-setup": "^1.0.0"
    },
    "extra": {
        "jelix": {
            "app-dir" : "myapp/",
            "var-config-dir" : "/var/lib/myapp/config/",
            "modules-dir" : [],
            "config-file-16": "mainconfig.ini.php"
        }
    }
}

debugging the plugin

Set an environnement variable JELIX_DEBUG_COMPOSER to true or create an empty file named JELIX_DEBUG_COMPOSER into the vendor directory., (*22)

After launching Composer, you will have a file jelix_debug.log into the vendor directory., (*23)

The Versions

26/09 2016

dev-master

9999999-dev http://jelix.org

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

  Sources   Download

MIT

The Requires

  • composer-plugin-api ^1.0

 

composer composer-plugin jelix

29/11 2015

0.3.2

0.3.2.0 http://jelix.org

Plugin for Composer to declare Jelix modules automatically

  Sources   Download

MIT

The Requires

  • composer-plugin-api ^1.0

 

composer composer-plugin jelix

21/05 2015

0.3.1

0.3.1.0 http://jelix.org

Plugin for Composer to declare Jelix modules automatically

  Sources   Download

MIT

The Requires

  • composer-plugin-api 1.0.0

 

composer composer-plugin jelix

30/04 2015

0.3

0.3.0.0 http://jelix.org

Plugin for Composer to declare Jelix modules automatically

  Sources   Download

MIT

The Requires

  • composer-plugin-api 1.0.0

 

composer composer-plugin jelix

27/04 2015

0.2

0.2.0.0 http://jelix.org

Plugin for Composer to setup modules automatically

  Sources   Download

MIT

The Requires

  • composer-plugin-api 1.0.0

 

composer composer-plugin jelix

27/04 2015

0.1

0.1.0.0 http://jelix.org

Plugin for Composer to setup modules automatically

  Sources   Download

MIT

The Requires

  • composer-plugin-api 1.0.0

 

composer composer-plugin jelix