Magento 2 Modules – How to Rebuild the Sequence

configurationmagento2module

TL:DR;
How can I rebuild (automatically) the modules sequence stored in app/etc/config.php in Magento 2.
Long version:
I have 2 modules I'm working on.
I installed them in the order "Module 1", "Module 2".
So in my app/etc/config.php they appear at the bottom like this:

'Magento_Wishlist' => 1, //core module
'Namespace_Module1' => 1, //my first module
'Namespace_Module2' => 1, //my second module

But after I installed both of them, I realized that Module2 must be loaded before Module1 so that some config settings from Module 2 can be overwritten through Module 1. (don't ask why, just bear with me).

So I edited the etc/module.xml file of "Module1" and added the "Module 2" inside the <sequence> tag.
But that has no effect, because the list of modules from config.php remains the same.
Is there a way to rebuild the sequence from config.php? I know that for 2 modules it should be easy because I can just edit it manually, but I'm curious if there is an automated way of doing it, in case I will need it in the future.

Best Answer

From the documentation: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/build/module-load-order.html

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>.

Related Topic