Magento 2: Enable/Disable Module via Command Line

This article shows how you can enable or disable Magento 2 modules using the command line. In my previous article, I have listed out all the command line tools that can be used in Magento 2. This article specifically shows about commands to enable/disable Magento 2 modules.

Get the List of All Modules

First of all, let’s get the list of all the modules in our Magento site. We can do so with the following command:


php bin/magento module:status

This will list out all the enabled and disabled modules.

Enable Modules

Suppose, I have two custom modules named Chapagain_GoogleTagManager & Chapagain_ClearPrint. Let’s suppose, these two modules are currently disabled. Now, to enable them, we need to use the following command:


php bin/magento module:enable Chapagain_GoogleTagManager Chapagain_ClearPrint

Note: You can specify single or multiple module names. Above, I have specified two module names.

Running the above command will output something like this:

The following modules have been enabled:
– Chapagain_GoogleTagManager
– Chapagain_ClearPrint

To make sure that the enabled modules are properly registered, run ‘setup:upgrade’.
Cache cleared successfully.
Generated classes cleared successfully. Please run the ‘setup:di:compile’ command to generate classes.
Info: Some modules might require static view files to be cleared. To do this, run ‘module:enable’ with the –clear-static-content option to clear them.

We have to run setup:upgrade command to properly register the recently enabled modules. This command clears cache and updates the modules and schemas.


php bin/magento setup:upgrade

Disable Modules

In the enable modules example above, we enabled two modules named Chapagain_GoogleTagManager & Chapagain_ClearPrint. Now, let’s disable these two modules.


php bin/magento module:disable Chapagain_GoogleTagManager Chapagain_ClearPrint

Note: You can specify single or multiple module names. Above, I have specified two module names.

Running the above command will output something like this:

The following modules have been disabled:
– Chapagain_GoogleTagManager
– Chapagain_ClearPrint

Cache cleared successfully.
Generated classes cleared successfully. Please run the ‘setup:di:compile’ command to generate classes.
Info: Some modules might require static view files to be cleared. To do this, run ‘module:disable’ with the –clear-static-content option to clear them.

Hope this helps. Thanks.