dependencies.rst 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. Plugin Dependencies
  2. ###################
  3. In Elgg 1.8 a plugin dependencies system was introduced to prevent plugins from being used on incompatible systems.
  4. .. contents:: Contents
  5. :local:
  6. :depth: 2
  7. Overview
  8. ========
  9. The dependencies system is controlled through a plugin's ``manifest.xml`` file. Plugin authors can specify that a plugin:
  10. - Requires certain Elgg versions, Elgg plugins, PHP extensions, and PHP settings.
  11. - Suggests certain Elgg versions, Elgg plugins, PHP extensions, and PHP settings.
  12. - Conflicts with certain Elgg versions or Elgg plugins.
  13. - Provides the equivalent of another Elgg plugin or PHP extension.
  14. 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:
  15. .. code:: xml
  16. <verb>
  17. <type>type</type>
  18. <noun>value</noun>
  19. <noun2>value2</noun2>
  20. </verb>
  21. .. note::
  22. ``type`` is always required
  23. Verbs
  24. =====
  25. 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``.
  26. Requires
  27. --------
  28. Using a ``requires`` dependency means that the plugin cannot be enabled unless the dependency is exactly met.
  29. Mandatory requires: elgg_version and elgg_release
  30. -------------------------------------------------
  31. 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 ``<comparison>`` element.
  32. Using elgg_version:
  33. .. code:: xml
  34. <requires>
  35. <type>elgg_version</type>
  36. <version>2011010401</version>
  37. </requires>
  38. Using elgg_release:
  39. .. code:: xml
  40. <requires>
  41. <type>elgg_release</type>
  42. <version>1.8</version>
  43. </requires>
  44. Suggests
  45. --------
  46. ``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.
  47. Suggest another plugin:
  48. .. code:: xml
  49. <suggests>
  50. <type>plugin</type>
  51. <name>twitter_api</name>
  52. <version>1.0</version>
  53. </suggests>
  54. Suggest a certain PHP setting:
  55. .. code:: xml
  56. <suggests>
  57. <type>php_ini</type>
  58. <name>memory_limit</name>
  59. <value>64M</value>
  60. <comparison>ge</comparison>
  61. </suggests>
  62. Conflicts
  63. ---------
  64. ``conflicts`` dependencies mean the plugin cannot be used under a specific system configuration.
  65. Conflict with any version of the profile plugin:
  66. .. code:: xml
  67. <conflicts>
  68. <type>plugin</type>
  69. <name>profile</name>
  70. </conflicts>
  71. Conflict with a specific version of Elgg:
  72. .. code:: xml
  73. <conflicts>
  74. <type>elgg_version</type>
  75. <version>2010112301</version>
  76. <comparison>==</comparison>
  77. </conflicts>
  78. Provides
  79. --------
  80. ``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``.
  81. 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.
  82. .. code:: xml
  83. <provides>
  84. <type>plugin</type>
  85. <name>twitter_services</name>
  86. <version>1.8</version>
  87. </provides>
  88. .. note::
  89. All plugins provide themselves as their plugin id (directory name) at the version defined in the their manifest.
  90. Types
  91. =====
  92. Every dependency verb has a mandatory ``<type>`` element that must be one of the following six values:
  93. 1. **elgg_version** - The API version of Elgg (2011010401)
  94. 2. **elgg_release** - The release version of Elgg (1.8)
  95. 3. **plugin** - An Elgg plugin
  96. 4. **priority** - A plugin load priority
  97. 5. **php_extension** - A PHP extension
  98. 6. **php_ini** - A PHP setting
  99. 7. **php_version** - A PHP version
  100. .. note::
  101. ``provides`` only supports ``plugin`` and ``php_extension`` types.
  102. Every type is defined with a dependency verb as the parent element. Additional option elements are at the same level as the type element:
  103. .. code:: xml
  104. <verb>
  105. <type>type</type>
  106. <option_1>value_1</option_1>
  107. <option_2>value_2</option_2>
  108. </verb>
  109. elgg_version and elgg_release
  110. -----------------------------
  111. These concern the API and release versions of Elgg and requires the following option element:
  112. - **version** - The API or release version
  113. The following option element is supported, but not required:
  114. - **comparison** - The comparison operator to use. Defaults to >= if not passed
  115. plugin
  116. ------
  117. Specifies an Elgg plugin by its ID (directory name). This requires the following option element:
  118. - **name** - The ID of the plugin
  119. The following option elements are supported, but not required:
  120. - **version** - The version of the plugin
  121. - **comparison** - The comparison operator to use. Defaults to >= if not passed
  122. priority
  123. --------
  124. 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:
  125. - **plugin** - The plugin ID to base the load order on
  126. - **priority** - The load order: 'before' or 'after'
  127. php_extension
  128. -------------
  129. This checks PHP extensions. The follow option element is required:
  130. - **name** - The name of the PHP extension
  131. The following option elements are supported, but not required:
  132. - **version** - The version of the extension
  133. - **comparison** - The comparison operator to use. Defaults to ==
  134. .. note::
  135. The format of extension versions varies greatly among PHP extensions and is sometimes not even set. This is generally worthless to check.
  136. php_ini
  137. -------
  138. This checks PHP settings. The following option elements are required:
  139. - **name** - The name of the setting to check
  140. - **value** - The value of the setting to compare against
  141. The following options are supported, but not required:
  142. - **comparison** - The comparison operator to use. Defaults to ==
  143. php_version
  144. -----------
  145. This checks the PHP version. The following option elements are required:
  146. - **version** - The PHP version
  147. The following option element is supported, but not required:
  148. - **comparison** - The comparison operator to use. Defaults to >= if not passed
  149. Comparison Operators
  150. ====================
  151. Dependencies that check versions support passing a custom operator via the ``<comparison>`` element.
  152. The follow are valid comparison operators:
  153. - < or lt
  154. - <= or le
  155. - =, ==, or eq
  156. - !=, <>, or ne
  157. - > or gt
  158. - >= or ge
  159. If ``<comparison>`` is not passed, the follow are used as defaults, depending upon the dependency type:
  160. - requires->elgg_version and elgg_release: >=
  161. - requires->plugin: >=
  162. - requires->php_extension: =
  163. - requires->php_ini: =
  164. - all conflicts: =
  165. .. note::
  166. You must escape < and > to ``&gt;`` and ``&lt;``. For comparisons that use these values, it is recommended you use the string equivalents instead!
  167. Quick Examples
  168. ==============
  169. Requires Elgg 1.8.2 or higher
  170. -----------------------------
  171. .. code:: xml
  172. <requires>
  173. <type>elgg_release</type>
  174. <version>1.8.2</version>
  175. </requires>
  176. Requires the Groups plugin is active
  177. ------------------------------------
  178. .. code:: xml
  179. <requires>
  180. <type>plugin</type>
  181. <name>groups</name>
  182. </requires>
  183. Requires to be after the Profile plugin if Profile is active
  184. ------------------------------------------------------------
  185. .. code:: xml
  186. <requires>
  187. <type>priority</type>
  188. <priority>after</priority>
  189. <plugin>profile</plugin>
  190. </requires>
  191. Conflicts with The Wire plugin
  192. ------------------------------
  193. .. code:: xml
  194. <conflicts>
  195. <type>plugin</type>
  196. <name>thewire</name>
  197. </conflicts>
  198. Requires at least 256 MB memory in PHP
  199. --------------------------------------
  200. .. code:: xml
  201. <requires>
  202. <type>php_ini</type>
  203. <name>memory_limit</name>
  204. <value>256M</value>
  205. <comparison>ge</comparison>
  206. </requires>
  207. Requires at least PHP version 5.3
  208. ---------------------------------
  209. .. code:: xml
  210. <requires>
  211. <type>php_version</type>
  212. <version>5.3</version>
  213. </requires>
  214. Suggest the TidyPics plugin is loaded
  215. -------------------------------------
  216. .. code:: xml
  217. <suggests>
  218. <type>plugin</type>
  219. <name>tidypics</name>
  220. </suggests>