0

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?

1 Answer 1

1

You can not enable/disable the module using env.php file, you have two options here:

  1. Disable modules config (using config path) in env.php
  2. Keep the 2FA modules enabled in config.php and disable the modules during the deployment in your CI process using:
bin/magento module:disable MODULE_NAME
3
  • For the first option, do you mean like the web\secure\base_url config? The second option will update the config.php file to the same status which makes it hard to keep the file updated in git especially if I have many modules disabled for development purposes (not only 2FA)
    – S.Murtadha
    Sep 20 at 6:44
  • 1
    That's correct, you can disable most of the features in Magento with config paths, like web\secure\base_url
    – Ahmad
    Sep 20 at 7:30
  • That's great for most of the modules, thanks Ahmed. However, I've tested this method for the 2FA module specifically and it doesn't do the job. I guess since the config variable twofactorauth/general/enabled is not being used correctly in the module (or maybe intentionally to enforce 2FA)
    – S.Murtadha
    Sep 20 at 8:29

Your Answer

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

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