How to Enable, Disable and Uninstall Magento 2 Modules Safely

Manage Magento 2 module states safely, understand uninstall risks, and deploy generated assets using current CLI practices.

Enabling, disabling and uninstalling a Magento 2 module are different operations. This updated guide preserves the original command-line workflow while replacing outdated root-user advice, blanket permission changes and recursive static-file deletion.

Before you begin

Test the change in staging, check the extension vendor's compatibility requirements, and back up the database, code, Composer files and deployment configuration. Run Magento and Composer as the Magento filesystem owner. Do not run Magento as root or add sudo to every command: incorrect ownership can break subsequent deployments.

The following examples use Vendor_Module as a placeholder. Use the PHP binary compatible with your installed Magento release. Perform production changes through your established deployment process and approved maintenance window.

cd /path/to/magento
php bin/magento --version
php bin/magento deploy:mode:show
php bin/magento module:status
php bin/magento module:status Vendor_Module
php bin/magento help module:enable
php bin/magento help module:disable

These checks do not enable or disable modules. Review composer.json, the extension documentation and command dependency errors before proceeding. Avoid --force: bypassing dependency checks can break the storefront or Admin.

Enable a Magento 2 module

Install the extension code through its supported distribution method first. Enabling a module does not download its package. In an approved deployment, run:

php bin/magento module:enable Vendor_Module
php bin/magento setup:upgrade
php bin/magento cache:clean

Enabling records the module state in app/etc/config.php. The upgrade command applies required database schema and data changes; review those changes and keep a database rollback plan. Complete the production build steps below before returning traffic.

Disable a Magento 2 module

php bin/magento module:disable Vendor_Module

This disables the module's participation in Magento configuration. It does not uninstall its Composer package or deliberately remove its data. However, dependency and database consequences still require staging validation. Do not run setup:upgrade indiscriminately after disabling a module: declarative-schema behavior and vendor-specific removal procedures must be reviewed first.

If another module depends on it, resolve the dependency through the documented deployment plan. After the change, rebuild the production artifacts where required and clean affected caches.

Compile and deploy static content when required

In production mode, module changes can require regenerated dependency injection and static assets. Adapt the build to the installed themes and languages:

php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy en_US
php bin/magento cache:clean

These commands modify generated output. Replace en_US with the deployed locales and follow your release pipeline. Developer and default modes normally generate static assets on demand; do not add forced static deployment as a routine step without a reason.

Where stale static files must be cleared, inspect the supported --clear-static-content option on the enable/disable command and prepare regeneration before using it. Avoid copied rm -rf recipes, obsolete var/generation instructions and blanket recursive ownership changes. Preserve protective files such as pub/static/.htaccess.

Maintenance mode and failed deployments

For an in-place production deployment, enable maintenance before the approved modifying steps:

php bin/magento maintenance:enable

Only after the build succeeds and application checks pass should you run:

php bin/magento maintenance:disable

If an upgrade, compilation or deployment fails, keep public traffic controlled, inspect logs, and repair or roll back the release. Restoring only the old code may be insufficient after database migrations. Coordinate cron and consumers with the deployment procedure.

Uninstalling is different from disabling

Uninstallation can remove code or data and should be a separate approved change. Inspect the installed command and the module vendor's procedure first:

php bin/magento help module:uninstall

For an eligible Composer-managed module, the basic modifying command is:

php bin/magento module:uninstall Vendor_Module

This is not a simulation. Review dependencies, the package relationship and uninstall implementation in staging. The optional --remove-data can invoke supported module data-removal logic; do not add it unless data removal is intended and recoverable. A manually installed module is not guaranteed to have its code removed by this command, and dependency checks depend on Composer metadata. Do not manually delete a directory before following the vendor's procedure.

Verify the result

php bin/magento module:status Vendor_Module
php bin/magento setup:db:status
php bin/magento cache:status

Check the storefront, affected pages, customer login, cart and checkout using an approved test. Verify the Admin feature, API integrations, cron, consumers and application logs. Review and commit the intended app/etc/config.php change; include Composer files when package installation or removal changed them.

Adobe Commerce Cloud deployments

On Adobe Commerce Cloud, make module-state changes in the appropriate development environment and deploy the configuration through the supported build/deploy workflow. Do not treat direct production shell changes as a durable deployment.

Official references and support

Need help planning an extension change or resolving a deployment issue? View Agile Codex Magento support packages.