Handling dependencies

Plugins can indicate if they depend upon certain conditions in order for them to work correctly. Two attributes are used to specify this: necessite and utilise. In the first case, the dependency is a strong one: a plugin that requires a resource (a certain version of SPIP or another particular plugin) can not be activated if that resource is not present and active. An error will be generated if we try to activate the plugin without that dependency being fulfilled. In the second case, the dependency is weak, and the plugin can be activated and perhaps even work even if that dependency is not fulfilled.

Necessite

  1. <necessite id="prefixe" version="[version_min;version_max]" />
  • id is the name of the plugin’s prefix, or "SPIP" for a direct dependency on SPIP itself,
  • version used optionally can indicate the mininum and/or maximum version of a plugin. Square brackets are used to indicate that the version as specified is included, parentheses to indicate that the version specified is not included.

Utilise

"Utilise" is therefore used to declare optional dependencies, with exactly the same syntax as for necessite.

utilise and necessite also therefore make it possible to override the files for the plugin that they refer to (as they have priority in the file path).

Example

  1. // requires at least SPIP 2.0
  2. <necessite id="SPIP" version="[2.0;)" />
  3. // requires SPIP < 2.0
  4. <necessite id="SPIP" version="[;2.0)" />
  5. // requires SPIP >= 2.0, and <= 2.1
  6. <necessite id="SPIP" version="[2.0;2.1]" />
  7.  
  8. // requires spip_bonux at least at version 1.2
  9. <necessite id="spip_bonux" version="[1.2;]" />

Download

Certain plugins may indicate that it is possible to modify their configurations if the CFG plugin is loaded (but without actually being an indispensable requirement for the plugin to work):

  1. // configuration plugin
  2. <utilise id="cfg" version="[1.10.5;]" />

Download

Author Mark Baber Published : Updated : 16/02/10

Translations : English, français