Skip to content

Using Env.php to Override Module Status in Config.php

What I am trying to achieve is overriding specific modules declared as enabled in the app/etc/config.php to be disabled by the app/etc/env.php file.

A use case of that would be the 2FA module which I prefer to keep as disabled in the development environments.

I tried adding the module to the env.php file as follows, but the config.php gets updated to 0 as well:

<?php
return [
    'modules' => [
        'Magento_TwoFactorAuth' => 0,
        'Vendor_DevModuleWhichShallNotBeTrackedByTheConfigFile' => 0
    ],
    ...
];

What would be the best practice for this situation? Should I remove the module from the config.php entirely and add it to each server env.php file separately?