# Declare plugin dependencies

[[toc]]

WARNING

This feature requires Blessing Skin v3.5.0 or later

During the development process, it is very common for a plugin to depend on another plugin; in addition, you may also want the plugin to make requirements on the version of Blessing Skin (for example, you may need a feature or function that is only available in a certain version of Blessing Skin) .

Starting with Blessing Skin v3.5.0, Blessing Skin's plugin system allows you to declare your plugin's dependencies in package.json .

# Where is it declared?

You just need to add requirefield in package.json whose value is a key-value pair.The key is the name of the dependency, and the value is the version. It is worth noting that when declaring the dependent version, you can use the Semantic Version, and Blessing Skin uses composer/semverto parse it internally.

# Identify the version of Blessing Skin

Although this is not required, we still recommend that you declare the version of Blessing Skin you require, because Blessing Skin will prompt a warning when enabling the plugin when it encounters a plugin that does not explicitly declare the version of Blessing Skin, which is not user-friendly.

The plug-in system has been added since Blessing Skin v3.2.0, so if your plug-in has no special version requirements, you can fill in ^3.2.0, and the package.jsonexample is as follows:

{
  "require" : {
    "blessing-skin-server" : "^3.2.0"
  } 
}

However, due to the existence of semantic version, if you fill in ^3.2.0, Blessing Skin will prevent your plugin from running on Blessing Skin v4 and above. If your plugin is simple enough, you can directly fill in *:

{
  "require" : {
    "blessing-skin-server" : "*"
  } 
}

You can also fill in ^3.2.0 || ^4.0.0. (but produces a different effect than *)

# Specify PHP version requirements

Starting with 5.0.0, you can specify your plugin's PHP version requirements. (Of course, if your plugin does not have such special requirements, ignore this item.)

Just declare the key as php, such as:

{
  "require" : {
    "php" : "^7.4"
  } 
}

After the statement above, if the PHP version used by the user is less than 7.4, the plug-in will not be able to be opened.

# Declare dependencies on other plugins

The method of declaring dependencies on other plug-ins is similar to the above, except that you should specify the specific plug-in namevalue (remember to namethe value instead of the name of the plug-in).

For example, suppose you are writing aplugin, and aplugin depends on bplugin, the version is ^1.0.0, you can write it like this:

{
  "require" : {
    "b" : "^1.0.0"
  } 
}

After this statement, if the user activates the aplug-in, but the bplug-in is not enabled or the version does not meet the requirements, the aplug-in cannot be enabled.