Module dependency types
Two types of dependencies
There are two types of Magento module dependencies: hard and soft dependencies.
Modules with a hard dependency on another module cannot function without the module it depends on. Specifically:
The module contains code that directly uses logic from another module (for example, the latter module’s instances, class constants, static methods, public class properties, interfaces, and traits).
The module contains strings that include class names, method names, class constants, class properties, interfaces, and traits from another module.
The module deserializes an object declared in another module.
The module uses or modifies the database tables used by another module.
Modules with a soft dependency on another module can function properly without the other module, even if it has a dependency upon it. Specifically:
The module directly checks another module’s availability.
The module extends another module’s configuration.
The module extends another module’s layout.
Note: If a module uses code from another module, it should declare the dependency explicitly.
Magento installs modules in the following order:
1) the module serving as a dependency for another module
2) the module dependent on it
Avoid creating the following dependencies:
Circular (both direct and indirect)
Dependencies between modules in different product layers
You can build dependencies between the modules belonging to different layers.
Dependencies in the Framework layer
Modules belonging to the Magento Framework can be used in the application layer by an explicit dependency.
Note: In this case, using interfaces is preferable to using classes.
You can build dependencies between classes in the Magento Framework even if they belong to different modules.
Dependencies in the Application layer
Modules belonging to the application layer cannot be used in the Magento Framework.
You can build dependencies between classes in the application layer, but these classes must belong to the same module. Dependencies between the modules of the application layer should be built only by the service contract or the service provider interface (SPI).