Enable / Disable Modules
Understanding module:enable and module:disable commands, writable app/etc/ directory, and config.php management.
Enable / Disable Modules
How to Enable or Disable Modules on Cloud
The Simple Workflow
Basic Process
- Run
bin/magento module:enableorbin/magento module:disablelocally - This updates
app/etc/config.php - Commit and push
app/etc/config.phpto git - Deployment automatically applies the changes
Important Fact
Remember that the app/etc/ directory is writable. This means you can safely modify config.php and env.php files.
Enabling a Module
bin/magento module:enable Command
Enable a Single Module
bin/magento module:enable Vendor_ModuleName
Enable Multiple Modules
bin/magento module:enable Vendor_Module1 Vendor_Module2 Vendor_Module3
Enable All Modules
bin/magento module:enable --all
What This Does:
- Updates
app/etc/config.php - Sets module status to
1(enabled) - Module becomes active in Magento
- Makes module code executable
Example: Enabling a Custom Module
bin/magento module:enable Bonlineco_CustomModule
Output:
The following modules have been enabled:
- Bonlineco_CustomModule
To make sure that the enabled modules are properly registered, run 'setup:upgrade'.
Disabling a Module
bin/magento module:disable Command
Disable a Single Module
bin/magento module:disable Vendor_ModuleName
Disable Multiple Modules
bin/magento module:disable Vendor_Module1 Vendor_Module2 Vendor_Module3
What This Does:
- Updates
app/etc/config.php - Sets module status to
0(disabled) - Module becomes inactive in Magento
- Module code is not executed
- Database schema from module remains (not rolled back)
Example: Disabling a Third-Party Module
bin/magento module:disable Vendor_ProblematicModule
Output:
The following modules have been disabled:
- Vendor_ProblematicModule
To make sure that the disabled modules are properly registered, run 'setup:upgrade'.
Important Note
Disabling a module does NOT remove its database tables or schema changes. It only prevents the module code from executing. Use module:uninstall to fully remove a module and its database changes.
What Happens to config.php
Understanding config.php Changes
config.php Structure
<?php
return [
'modules' => [
'Magento_AdminAnalytics' => 1,
'Magento_Store' => 1,
'Magento_AdobeIms' => 1,
'Vendor_CustomModule' => 1, // Enabled (1)
'Vendor_DisabledModule' => 0, // Disabled (0)
'Bonlineco_Example' => 1,
// ... more modules
],
'scopes' => [
// ... store configuration
],
'system' => [
// ... system configuration
]
];
| Module Status | Value in config.php | Meaning |
|---|---|---|
| Enabled | 'Vendor_Module' => 1 |
Module is active, code executes |
| Disabled | 'Vendor_Module' => 0 |
Module is inactive, code doesn't execute |
| Not Listed | Module not in array | Module not installed/registered |
Complete Workflow for Cloud
Step-by-Step: Disabling a Module on Cloud
Scenario: Disable a Problematic Module
You need to disable Vendor_ProblematicModule because it's causing errors.
| Step | Command/Action | Location | Notes |
|---|---|---|---|
| 1 | git checkout -b disable-module |
Local | Create new branch |
| 2 | bin/magento module:disable Vendor_ProblematicModule |
Local | Disable the module |
| 3 | git diff app/etc/config.php |
Local | Verify change (1 → 0) |
| 4 | git add app/etc/config.php |
Local | Stage the change |
| 5 | git commit -m "Disable Vendor_ProblematicModule" |
Local | Commit to branch |
| 6 | git push origin disable-module |
Local | Push to Cloud |
| 7 | Monitor deployment | Cloud | Deployment runs automatically |
| 8 | Test environment | Cloud | Verify module is disabled |
| 9 | Merge to staging/production | Cloud | After successful testing |
The app/etc/ Directory
Understanding Writable Directories
app/etc/ is Writable
The app/etc/ directory is writable in Cloud environments. This is important because:
- You can safely modify
config.php - You can modify
env.php(though not recommended) - Module enable/disable commands work without issues
- Configuration management is possible
Writable vs Read-Only Directories
| Directory | Status | Purpose |
|---|---|---|
app/etc/ |
Writable | Configuration files (config.php, env.php) |
var/ |
Writable | Cache, logs, session, page_cache |
pub/media/ |
Writable | Product images, customer uploads |
pub/static/ |
Writable (conditionally) | Static content (writable with SCD_ON_DEMAND) |
generated/ |
Read-Only | Generated code (factories, interceptors) |
app/code/ |
Read-Only | Custom modules |
vendor/ |
Read-Only | Composer dependencies |
Checking Module Status
Useful Commands
List All Modules and Their Status
bin/magento module:status
Output:
List of enabled modules:
Magento_AdminAnalytics
Magento_Store
Vendor_CustomModule
Bonlineco_Example
List of disabled modules:
Vendor_DisabledModule
Vendor_ProblematicModule
Check Specific Module in config.php
grep "Vendor_ModuleName" app/etc/config.php
Output:
'Vendor_ModuleName' => 1,
View All Module Settings
cat app/etc/config.php | grep -A 50 "'modules'"
Common Use Cases
When to Enable/Disable Modules
Use Case 1: Troubleshooting
Scenario:
A third-party extension is causing errors. You need to quickly disable it to restore site functionality.
Solution:
bin/magento module:disable Vendor_ProblematicModule
git add app/etc/config.php
git commit -m "Disable problematic module"
git push
Use Case 2: Installing New Extension
Scenario:
After installing a new extension via Composer, you need to enable it.
Solution:
composer require vendor/new-extension
bin/magento module:enable Vendor_NewExtension
git add app/etc/config.php composer.json composer.lock
git commit -m "Add new extension"
git push
Use Case 3: Temporarily Disabling Features
Scenario:
You want to temporarily disable a feature module during peak traffic.
Solution:
bin/magento module:disable Vendor_HeavyFeatureModule
git add app/etc/config.php
git commit -m "Temporarily disable heavy feature"
git push
# Later, re-enable:
bin/magento module:enable Vendor_HeavyFeatureModule
git add app/etc/config.php
git commit -m "Re-enable feature module"
git push
Important Considerations
Best Practices and Warnings
Best Practices
- Test first: Always disable modules in integration environment first
- Commit config.php: Essential for changes to propagate
- Check dependencies: Some modules depend on others
- Use clear commit messages: Document why you disabled/enabled module
- Monitor deployment: Watch for errors during deployment
- Test thoroughly: Ensure functionality works after disabling modules
Important Warnings
- Dependencies: Disabling a module may break modules that depend on it
- Database remains: Disabled modules' database tables remain (not removed)
- No setup:upgrade in Cloud: This runs automatically during deployment
- Core modules: Be extremely careful disabling Magento core modules
- Payment/shipping: Disabling these can break checkout
Critical: Module Dependencies
Before disabling a module, check if other modules depend on it:
bin/magento module:status Vendor_ModuleName
If other modules depend on it, you must disable those first or risk breaking your site!
Difference: Enable/Disable vs Uninstall
Understanding the Options
| Action | Command | Code Execution | Database Tables | Files |
|---|---|---|---|---|
| Enable | module:enable |
✅ Executes | ✅ Remains | ✅ Remains |
| Disable | module:disable |
❌ Doesn't execute | ✅ Remains | ✅ Remains |
| Uninstall | module:uninstall |
❌ Doesn't execute | ❌ Removed (if uninstall script exists) | ❌ Removed (Composer only) |
When to Use Each
- Enable: Activate a module's functionality
- Disable: Temporarily turn off a module (troubleshooting, performance)
- Uninstall: Completely remove a module and its database changes
Troubleshooting
Common Issues and Solutions
Issue 1: Module Won't Disable
Error Message:
Cannot disable module 'Vendor_Module' because modules depend on it
Solution:
- Find dependent modules:
bin/magento module:status - Disable dependent modules first
- Then disable the target module
- Or accept you cannot disable due to dependencies
Issue 2: Changes Not Applied After Push
Possible Causes:
- config.php not committed to git
- Deployment failed
- Cache not cleared
Solution:
- Verify config.php is committed:
git log --oneline app/etc/config.php - Check deployment logs for errors
- Clear cache:
bin/magento cache:flush - Verify module status:
bin/magento module:status
Issue 3: Site Breaks After Disabling Module
Cause:
Other modules or custom code depend on the disabled module.
Solution:
- Check error logs:
var/log/system.log,var/log/exception.log - Identify dependent functionality
- Either re-enable the module or fix dependent code
- Always test in integration environment first!
Exam Tips
Key Points to Remember
- Enable command: bin/magento module:enable Vendor_Module
- Disable command: bin/magento module:disable Vendor_Module
- Updates file: app/etc/config.php
- Enabled value: 1 in config.php
- Disabled value: 0 in config.php
- app/etc/ directory: WRITABLE (can safely modify)
- Workflow: Run command locally → commit config.php → push to git
- Multiple modules: Can enable/disable multiple at once
- Check status: bin/magento module:status
- Database tables: Remain even when module is disabled
- Uninstall difference: module:uninstall removes database tables (if script exists)
- Dependencies: Check before disabling (may break dependent modules)
- Must commit: config.php to git for changes to deploy