How to Enable/Disable Module in Magento 2 via Command Line

Magento 2 has many numbers of modules which are used to perform its own operation also it may work with other modules. All the Magento 2 modules are placed in the < Magento 2 Root >/vendor/magento directory and all the third party modules are placed in the < Magento 2 Root >/app/code directory. Sometimes we may need to disable some unwanted modules and later we may enable it. For that, this quick article will help you to enable or disable Magento 2 modules using the command line.

Login to Magento 2 File System:

First, Login to your Magento 2 installation using SSH via Terminal or Putty.

Example:

cd /var/www/html/magento2/

Get the List of All Modules:

Once logged in to Magento 2 file system using SSH, first we need to get the list of all the modules in our Magento 2. We can do this with the following command:

php bin/magento module:status

This will list out all the enabled and disabled modules.

Enable Modules:

By default, all the new module will be in disabled status. We have to enable it & install them. The following command is used to enable the module,

php bin/magento module:enable BlogTreat_HelloWorld

In the above code, BlogTreat_HelloWorld is the module name. We can enable single or multiple modules at the same time.

Here the example command to enable multiple modules,

php bin/magento module:enable BlogTreat_HelloWorld BlogTreat_MegaMenu

After enabling the module, run the following command to install the module,

php bin/magento setup:upgrade

Disable Modules:

The following command is used to disable the module,

php bin/magento module:disable BlogTreat_HelloWorld

In the above code, BlogTreat_HelloWorld is the module name. We can disable single or multiple modules at the same time.

Here the example command to disable multiple modules,

php bin/magento module:disable BlogTreat_HelloWorld BlogTreat_MegaMenu

After disabling the module, run the following command to update the Magento 2 database,

php bin/magento setup:upgrade

Note:

  • If module A depends on module B:
    • It is required to disable the module A before disabling the module B.
    • It is required to enable the module B before enabling the module A if both are unavailable.
  • All the modules status are available in < Magento 2 Root >/app/etc/config.php file. Whenever we enable/disable the modules, the module status will be updated in this file. ( Status: 1 => Enabled, 0 => Disabled ).

Hope this helps.

Leave a Reply

Your email address will not be published. Required fields are marked *