Dependencies

από Elxis Team

Depend an extension on other extensions or the Elxis core.

Elxis 4.x introduces extension dependencies. On the extension's XML file you can declare other extensions on which this extension depends to. A dependency can be seen as a requirement. Elxis installer will throw a warning if dependencies are not fulfilled and will ask the user for an action. The user can ignore the warning and continue the installation or cancel the installation.

Declare dependencies

Let's say we have created a module which loads data from a component's database tables. If this component doesn't exist (is not installed) or its version is not the right one the module will fail loading the required data. So, this module depends on the specific component. You can declare this dependency on the module's installation XML file. Here is a sample.

<dependencies>
	<dependency type="core" version="4.x">elxis</dependency>
	<dependency type="component" version="1.2+">sample</dependency>
	<dependency type="module" version="1.0,1.1">test</dependency>
	<dependency type="plugin" version="1.4+,2.x">example</dependency>
</dependencies>

You can declare as many dependencies your extension requires.

Extension type

The type attribute declares the dependant extension type. It can be component, module, template, atemplate, engine, auth, plugin and core. In case of core the extension depends on Elxis itself.

Extension version

The version attribute provides compatibility information. Two keywords are supported, x (matching keyword) and + (greater or equal than).

The first dependecny on the above example inform us that the extension we are going to install requires Elxis 4.x, which means that it is compatible to Elxis 4.0, 4.1, 4.2, ..., and 4.9. But NOT compatible to 3.9 or 5.0.

The second dependency on the above example inform us that the extension we are going to install requires component sample (com_sample) version 1.2 or greater (1.2+). This means that it is compatible to component sample 1.2, 1.3, 1.4, ..., and 1.9, but NOT compatible to component sample 1.0, 1.1 or 2.0.

The third dependency on the above example doesn't have any keywords in the version attribute but 2 standard versions comma separated. It declares that the extension requires module test (mod_test) of version 1.0 or 1.1. All other versions of module test are incompatible to this extension.

The forth dependency on the above example inform us that the extension we are going to install requires plugin example (example) version 1.4 or greater (1.4+) OR any version of the 2.x series. This means that it is compatible to plugin example 1.4, 1.5, 1.6, ..., and 1.9, also compatible to 2.0, 2.1, 2.2, ..., and 2.9, but NOT compatible to plugin example 1.0, 1.1, 1.2, 1.3 or 3.0 and above.

Έχει διαβαστεί 4131 φορές
Ετικέτες: dependencies extensions
Icon packages
Προηγούμενο άρθρο
Icon packages
PHP constants
Επόμενο άρθρο
PHP constants

Μπορείτε να αντιγράψετε, διανείμετε και παρουσιάσετε τα άρθρα αυτού του ιστότοπου για μη εμπορικούς σκοπούς.
Creative Commons 3.0