Enable and Disable Magento 2 Module

First Steps:

Ensure that you are login into the terminal using either as Magento file system owner (recommended) or as root user.
If you are not site system owner, you need to put “sudo” before every command.

Before doing the following commands, go to the Magento root Directory

cd <your Magento install dir>


Module enable:

To enable a module, run the following commands:

php -f bin/magento module:enable {ModuleName} php -f bin/magento setup:upgrade

a) Above the first command adds or enables your module {ModuleName} to the modules list.

b) Second command triggers setup scripts to install your Modules which is needed to setup.


Module Disable:

To enable a module, run the following command:

php bin/magento module:disable {ModuleName}


Module Uninstall:

To uninstall a module, run the following command:

php bin/magento module:uninstall {ModuleName}

This command executes the instillation, and deletes the module afterwards. Only the modules, installed through Composer, can be uninstalled in this way.


Deploy static view files:

After enabling, disabling or uninstalling a module, it’s better to deploy static content. Because, many modules have static files to be generated. To deploy, run the following commands:
Make sure there is no space around “/” before running following commands.

rm -rf pub/static/*/*; rm -rf var/*/*; 
php -f bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

a) First command cleans every folder from the var directory.

b) Second command deploys static view files.

c) Third command cleans and flushes cache.

If you are not logged as Magento file system owner, you need to have appropriate permissions of the files and directories by running below commands:

sudo chown -R <user>:<group> . 

Related Posts

Comments (1)

Sorry, the comment form is closed at this time.

Let us know about your project!

We’d love to know more about your project and give estimation.