Plugin Dependencies
###################
In Elgg 1.8 a plugin dependencies system was introduced to prevent plugins from being used on incompatible systems.
.. contents:: Contents
:local:
:depth: 2
Overview
========
The dependencies system is controlled through a plugin's ``manifest.xml`` file. Plugin authors can specify that a plugin:
- Requires certain Elgg versions, Elgg plugins, PHP extensions, and PHP settings.
- Suggests certain Elgg versions, Elgg plugins, PHP extensions, and PHP settings.
- Conflicts with certain Elgg versions or Elgg plugins.
- Provides the equivalent of another Elgg plugin or PHP extension.
The dependency system uses the four verbs above (``requires``, ``suggests``, ``conflicts``, and ``provides``) as parent elements to indicate what type of dependency is described by its children. All dependencies have a similar format with similar options:
.. code:: xml
type
value
value2
.. note::
``type`` is always required
Verbs
=====
With the exception of ``provides``, all verbs use the same six types with differing effects, and the type options are the same among the verbs. ``provides`` only supports ``plugin`` and ``php_extension``.
Requires
--------
Using a ``requires`` dependency means that the plugin cannot be enabled unless the dependency is exactly met.
Mandatory requires: elgg_version and elgg_release
-------------------------------------------------
Every plugin must have at least one requires: the version of Elgg the plugin is developed for. This is specified either by the Elgg API ``version`` (2011010401) or the ``release`` (1.8). The default comparison ``>=``, but you can specify your own by passing the ```` element.
Using elgg_version:
.. code:: xml
elgg_version
2011010401
Using elgg_release:
.. code:: xml
elgg_release
1.8
Suggests
--------
``suggests`` dependencies signify that the plugin author suggests a specific system configuration, but it is not required to use the plugin. The suggestions can also be another plugin itself which could interact, extend, or be extended by this plugin, but is not required for it to function.
Suggest another plugin:
.. code:: xml
plugin
twitter_api
1.0
Suggest a certain PHP setting:
.. code:: xml
php_ini
memory_limit
64M
ge
Conflicts
---------
``conflicts`` dependencies mean the plugin cannot be used under a specific system configuration.
Conflict with any version of the profile plugin:
.. code:: xml
plugin
profile
Conflict with a specific version of Elgg:
.. code:: xml
elgg_version
2010112301
==
Provides
--------
``provides`` dependencies tell Elgg that this plugin is providing the functionality of another plugin or PHP extension. Unlike the other verbs, it only supports two types: ``plugin`` and ``php_extension``.
The purpose of this is to provide interchangeable APIs implemented by different plugins. For example, the twitter_services plugin provides an API for other plugins to Tweet on behalf of the user via curl and Oauth. A plugin author could write a compatible plugin for servers without curl support that uses sockets streams and specify that it provides twitter_services. Any plugins that suggest or require twitter_services would then know they can work.
.. code:: xml
plugin
twitter_services
1.8
.. note::
All plugins provide themselves as their plugin id (directory name) at the version defined in the their manifest.
Types
=====
Every dependency verb has a mandatory ```` element that must be one of the following six values:
1. **elgg_version** - The API version of Elgg (2011010401)
2. **elgg_release** - The release version of Elgg (1.8)
3. **plugin** - An Elgg plugin
4. **priority** - A plugin load priority
5. **php_extension** - A PHP extension
6. **php_ini** - A PHP setting
7. **php_version** - A PHP version
.. note::
``provides`` only supports ``plugin`` and ``php_extension`` types.
Every type is defined with a dependency verb as the parent element. Additional option elements are at the same level as the type element:
.. code:: xml
type
value_1
value_2
elgg_version and elgg_release
-----------------------------
These concern the API and release versions of Elgg and requires the following option element:
- **version** - The API or release version
The following option element is supported, but not required:
- **comparison** - The comparison operator to use. Defaults to >= if not passed
plugin
------
Specifies an Elgg plugin by its ID (directory name). This requires the following option element:
- **name** - The ID of the plugin
The following option elements are supported, but not required:
- **version** - The version of the plugin
- **comparison** - The comparison operator to use. Defaults to >= if not passed
priority
--------
This requires the plugin to be loaded before or after another plugin, if that plugin exists. ``requires`` should be used to require that a plugin exists. The following option elements are required:
- **plugin** - The plugin ID to base the load order on
- **priority** - The load order: 'before' or 'after'
php_extension
-------------
This checks PHP extensions. The follow option element is required:
- **name** - The name of the PHP extension
The following option elements are supported, but not required:
- **version** - The version of the extension
- **comparison** - The comparison operator to use. Defaults to ==
.. note::
The format of extension versions varies greatly among PHP extensions and is sometimes not even set. This is generally worthless to check.
php_ini
-------
This checks PHP settings. The following option elements are required:
- **name** - The name of the setting to check
- **value** - The value of the setting to compare against
The following options are supported, but not required:
- **comparison** - The comparison operator to use. Defaults to ==
php_version
-----------
This checks the PHP version. The following option elements are required:
- **version** - The PHP version
The following option element is supported, but not required:
- **comparison** - The comparison operator to use. Defaults to >= if not passed
Comparison Operators
====================
Dependencies that check versions support passing a custom operator via the ```` element.
The follow are valid comparison operators:
- < or lt
- <= or le
- =, ==, or eq
- !=, <>, or ne
- > or gt
- >= or ge
If ```` is not passed, the follow are used as defaults, depending upon the dependency type:
- requires->elgg_version and elgg_release: >=
- requires->plugin: >=
- requires->php_extension: =
- requires->php_ini: =
- all conflicts: =
.. note::
You must escape < and > to ``>`` and ``<``. For comparisons that use these values, it is recommended you use the string equivalents instead!
Quick Examples
==============
Requires Elgg 1.8.2 or higher
-----------------------------
.. code:: xml
elgg_release
1.8.2
Requires the Groups plugin is active
------------------------------------
.. code:: xml
plugin
groups
Requires to be after the Profile plugin if Profile is active
------------------------------------------------------------
.. code:: xml
priority
after
profile
Conflicts with The Wire plugin
------------------------------
.. code:: xml
plugin
thewire
Requires at least 256 MB memory in PHP
--------------------------------------
.. code:: xml
php_ini
memory_limit
256M
ge
Requires at least PHP version 5.3
---------------------------------
.. code:: xml
php_version
5.3
Suggest the TidyPics plugin is loaded
-------------------------------------
.. code:: xml
plugin
tidypics