Component load order

You may need to specify your component’s dependency on other components or files from other components using your component’s composer.json. Further, you can specify a load order in your component’s module.xml file using the <sequence> tag to ensure that needed files from other components are already loaded when your component loads.

<sequence> declares the list of components that must be loaded before the current component is loaded. It’s used for loading different kind of files: configuration files, view files (including CSS, LESS, and template files), or setup classes. Note that <sequence> does not affect the loading of regular classes (non-setup classes).
Setup classes are classes in the component that create or update database schema
or data.

If you know that your component’s logic depends on something in another component, then you should add this component to require in composer.json and <sequence> in module.xml.

You can check your module’s load order from the <your Magento install dir>/app/etc/config.php file after you’ve successfully set up Magento. This file is created dynamically at run time during set up.

If you change the component load order using <sequence>, you must regenerate the component list in config.php; otherwise, the load order does not take effect.

Currently, the only way to do this is to enable the component using magento module:enable <module-list>, where <module-list> is the component or components to which you added <sequence>.

Examples

Assume you have a component that needs a configuration file from another component:

Component A introduces gadgetlayout.xml, which updates block gadgetBlock from component B. In this case, layout files from component A should be loaded before component B, so you should specify that in component B’s<sequence> entry in module
.xml. In other words, component B is dependent on component A. That is to say: