How to Enable or Disable Magento 2 Module using Command Lines

as a Magento 2 store owner sometimes you need to Disable a module for testing purposes or anything else.

it’s easy to do it with command lines!

First Of all, you need to connect to your server using SSH.

after connect go to Magento 2 Directory using CD command.

cd /var/www/example

just replace /var/www/example with magento installment directory.

How to Enable Magento 2 module using a command line

run this command

php bin/magento module:enable Vendor_Module

don’t forget to change Vendor_Module with the module name, you could find the module name in the registration.php file.

How to Disable Magento 2 module using a command line

run this command

php bin/magento module:disable Vendor_Module

if you need to clear static content and generated files add –clear-static-content to the end of the command line.

e.g:

php bin/magento module:enable Vendor_Module --clear-static-content

php bin/magento module:disable Vendor_Module --clear-static-content

if you need to force the command line to run add -f to the end of the command line.

e.g:

php bin/magento module:enable Vendor_Module --clear-static-content -f

OR

php bin/magento module:enable Vendor_Module -f

What to Do after Enable or Disable Magento 2 Module?

after enabling or disabling Magento 2 modules, you need to upgrade the database again and clean the cache, you also maybe need to deploy the static content again if you’re using Production mode.

you can do this by running these command lines.

php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy {{en_US ar_SA}}

php bin/magento cache:clean

replace en_US ar_SA with the locales you are using in your store.

Easy peasy right?!

if you need any assistant post a comment and I’ll answer you as soon as possible.

Thanks

Share this article:

Leave a Reply

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