-
-
Notifications
You must be signed in to change notification settings - Fork 2
Module loading
Module load order can be influenced by defining sequnce nodes in any module.xml.
@todo Does defining other modules in composer.json require affect the load order?
The sorted order of modules is then written to app/etc/config.php.
@todo Does app/etc/config.php represent the final sorted load order of modules then? Verify this.
Module load order can be affected by the sequence node.
When a component (module/theme/setup/language/library) is added as children to the sequence node, they will be loaded before the module.
Module sequence-ing affects the load order of config XML, layout XML, view files (CSS, Less, template files) and resource classes. Note that it is only resource PHP classes which are affected, the loading of all other PHP classes are not affected.
As a rule of thumb,
Given this module.xml file:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_ComponentB" setup_version="0.0.1">
<sequence>
<!-- Vendor_ComponentB is dependent on Vendor_ComponentA: -->
<module name="Vendor_ComponentA" />
</sequence>
</module>
</config>The load order of components would be:
- Anything that
Vendor_ComponentArequires (i.e. Anything thatVendor_ComponentAdefines in itssequencenode) is loaded first. - Anything in
Vendor_ComponentAis loaded - Anything in
Vendor_ComponentBis loaded
Modules are loaded in alphabetical order initially.
Then they are sorted into 'buckets', according to Magento_ vendor name.
They are then sorted by the order of sequence nodes.
Whenever a sequence node is edited, app/etc/config.php must be updated, by running bin/magento module:enable {{MODULE_NAME}}