Does the order in which modules are mentioned in app/etc/config.php matter for Magento 2?

I have looked closely at the code, but could not find any logic to the sorting of the modules. I know the config.php file is auto-generated.

Now assume that we manually edit the file (which you shouldn't do normally), does the order in which the modules are placed matter?

There is also a ticket on Github that relates to this, but I cannot tell what the current situation is with regards to the sequence being important or not:


4 Answers 4


AKAIK - all the modules namespace are listed in config.php file and there order is not matter at all.

Actually that specific modules value is matter most over here like 0 and 1

when you have value of 1 that means module is enabled

when you have value of 0 that means module is disabled

apart from that - order of the module listing is not matter at all , but while you are editing the file you need to take care that syntax should be a proper otherwise if you put value of first module on the last and value of last module on the first but its value is proper then its not matter at all.


modules listing is depend on app/etc/config.php .

The module which is listed at first at config.phpwill load first.

Yes, if you will edit config.php manually then the loading of the modules will change accordingly


We had a similar issue, where the ordering of modules changing was causing us problems, this is the solution we came up with: https://github.com/zero1limited/magento2-PreserveModuleOrderingInProductionMode


The modules are loaded in the order they are mentioned in config.php as interpreted by the following quote from devdocs;

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

Reference : https://devdocs.magento.com/guides/v2.4/extension-dev-guide/build/module-load-order.html

I also did some digging myself and found that if you mention the sequence in a module.xml the the dependent module is loaded before the current module.

<?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">
        <!-- Vendor_ComponentB is dependent on Vendor_ComponentA: -->
            <module name="Vendor_ComponentA" />

According to above module.xml module A will be listed before module B in config.php and hence, loaded before the module B. Note that they may not be listed in the neighbouring nodes but the general order will be as expected always.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.