Categories
Magento 2

Magento 2 module dependency – hard and soft dependencies

In this article today I will disuse about Magento 2 module dependency. In Magento 2 we can use two types of Magento module dependencies “Hard Dependency” and “Soft Dependency

Magento 2 dependencies of modules are defined in composer.json. Hard in section require, soft in section suggest

Magento 2 HARD dependency

Module with a hard dependency on another module cannot function without the module it depends on. In app/code/Vendor/Module/composer.json require section contains hard dependency definitions for the module.

For example:

Magento 2 SOFT dependency

We can set SOFT dependency by two way – One is make dependency on suggest section on Vendor/Module/composer.json, another one is sequence node of Vendor/Module/etc/module.xml file.

Module with a SOFT dependency on another module can function properly without the other module, even if it has a dependency on the other module. In app/code/Vendor/Module/composer.json suggest section contains soft dependency definitions for the module.

For example:

The sequence node of app/code/Vendor/Module/etc/module.xml file file also contains soft dependency definitions for the module.

Thank you for carefully read my article If you have any query please Leave your query on following comment section or contact with us. Please SHARE this post.