Inspired by a tweet by Erik Hansen, I take up the opportunity to write down a technique which is used in our projects frequently. I have first seen it introduced by my colleague Fabian Schmengler.
As described in our article Cut load times by up to 40% – Why and How to disable unused Magento 2 core modules, it sometimes makes sense to disable core modules for performance or security reasons. There, I presented the default way to disable a module:
bin/magento module:disable Magento_Marketplace
However, there are two drawbacks of that method:
1. The module files are still there, the module is just disabled and can be enabled again by accident.
2. If you run integration tests, they are run with all modules active – including the disabled modules.
Thus, we need a method to remove the modules.
Composer to the Rescue
As those modules are loaded via composer as dependencies, we cannot simply remove them from the composer.json. Instead, we use the replace functionality of Composer to replace them with nothing:
1 2 3 4 5 6 7 8 |
"require": { [...] }, "replace": { "magento/module-marketplace": "*" }, "config": { [...] |
If you call composer update now, the module(s) will be removed from the codebase.
Example for Magento 2.2.3
In one of our projects, this is the composer setup we use:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
"require": { [...] }, "replace": { "magento/module-admin-notification": "*", "magento/module-dhl": "*", "magento/module-fedex": "*", "magento/module-marketplace": "*", "magento/module-multishipping": "*", "magento/module-captcha": "*", "magento/module-persistent": "*", "magento/module-catalog-rule-configurable": "*", "magento/module-authorizenet": "*", "magento/module-google-adwords": "*", "magento/module-sample-data": "*", "magento/module-send-friend": "*", "magento/module-swagger": "*", "magento/module-swatches": "*", "magento/module-swatches-layered-navigation": "*", "magento/module-tax-import-export": "*", "magento/module-google-optimizer": "*", "magento/module-ups": "*", "magento/module-encryption-key": "*", "magento/module-usps": "*", "magento/module-braintree": "*", "magento/module-webapi-security": "*", "magento/module-signifyd": "*", "temando/module-shipping-m2": "*", "shopialfb/facebook-module": "*" }, "config": { [...] |
Extended Example for Magento 2.2.4
For Magento 2.2.4 or following, you’ll probably want to add some more modules to the list. Our list looks as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
"require": { [...] }, "replace": { "magento/module-admin-notification": "*", "magento/module-dhl": "*", "magento/module-fedex": "*", "magento/module-marketplace": "*", "magento/module-multishipping": "*", "magento/module-captcha": "*", "magento/module-persistent": "*", "magento/module-catalog-rule-configurable": "*", "magento/module-authorizenet": "*", "magento/module-google-adwords": "*", "magento/module-sample-data": "*", "magento/module-send-friend": "*", "magento/module-swagger": "*", "magento/module-swatches": "*", "magento/module-swatches-layered-navigation": "*", "magento/module-tax-import-export": "*", "magento/module-google-optimizer": "*", "magento/module-ups": "*", "magento/module-encryption-key": "*", "magento/module-usps": "*", "magento/module-braintree": "*", "magento/module-webapi-security": "*", "magento/module-signifyd": "*", "magento/module-analytics": "*", "magento/module-catalog-analytics": "*", "magento/module-customer-analytics": "*", "magento/module-quote-analytics": "*", "magento/module-review-analytics": "*", "magento/module-sales-analytics": "*", "magento/module-wishlist-analytics": "*", "temando/module-shipping-m2": "*", "dotmailer/dotmailer-magento2-extension": "*", "shopialfb/facebook-module": "*", "klarna/module-kp": "*", "klarna/module-ordermanagement": "*", "klarna/module-core": "*", "amzn/amazon-pay-and-login-magento-2-module": "*", "vertex/module-tax": "*" }, "config": { [...] |
Extended Example for Magento 2.2.6
Only one thing has changed in Magento 2.2.6 compared to 2.2.4 and 2.2.5: The amazon pay module has been split into smaller modules. The updated snippet which we use as a base for projects looks as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
"require": { [...] }, "replace": { "magento/module-admin-notification": "*", "magento/module-dhl": "*", "magento/module-fedex": "*", "magento/module-marketplace": "*", "magento/module-multishipping": "*", "magento/module-captcha": "*", "magento/module-persistent": "*", "magento/module-catalog-rule-configurable": "*", "magento/module-authorizenet": "*", "magento/module-google-adwords": "*", "magento/module-sample-data": "*", "magento/module-send-friend": "*", "magento/module-swagger": "*", "magento/module-swagger-webapi": "*", "magento/module-swatches": "*", "magento/module-swatches-layered-navigation": "*", "magento/module-tax-import-export": "*", "magento/module-google-optimizer": "*", "magento/module-ups": "*", "magento/module-usps": "*", "magento/module-braintree": "*", "magento/module-signifyd": "*", "magento/module-analytics": "*", "magento/module-catalog-analytics": "*", "magento/module-customer-analytics": "*", "magento/module-quote-analytics": "*", "magento/module-review-analytics": "*", "magento/module-sales-analytics": "*", "magento/module-wishlist-analytics": "*", "temando/module-shipping-m2": "*", "dotmailer/dotmailer-magento2-extension": "*", "shopialfb/facebook-module": "*", "klarna/module-kp": "*", "klarna/module-ordermanagement": "*", "klarna/module-core": "*", "amzn/amazon-pay-sdk-php": "*", "amzn/amazon-pay-and-login-with-amazon-core-module": "*", "amzn/login-with-amazon-module": "*", "amzn/amazon-pay-module": "*", "vertex/module-tax": "*" }, "config": { [...] |
Update for Magento 2.3
There is a seperate blog post about which modules can be removed from Magento 2.3.
Update
There is a valuable addition to that approach, created and shared by Cyrill Schumacher. In his blog post “Magento2 mock classes for removed core modules” he describes how you can remove even more core modules from your project if you don’t need them.

Author: Andreas von Studnitz
Andreas von Studnitz is a Magento developer and one of the Managing Directors at integer_net. His main areas of interest are backend development, Magento consulting and giving developer trainings. He is a Magento 2 Certified Professional Developer Plus and holds several other Magento certifications for both Magento 1 and Magento 2. Andreas was selected as a Magento Master in 2019 and 2020.
Thx for this article, we are going to test this on our Magento 2 store.
don’t know about this before. Thanks for sharing 🙂 Will surely try
Thank you for the list, it’s very usefull! I already disabled a lot of them 🙂
Thanks for the article. It is nice to reduce the cruft in Magento.
I came across an issue today that I wanted to document for others who might run into this. If you remove the Magento_AdminNotification module, product export will break.
When exporting products, the FileFactory is returned (vendor/magento/module-backend/App/Response/Http/FileFactory.php). When rendering the file, $this->_auth->getAuthStorage()->isFirstPageAfterLogin() is called. When calling isFirstPageAfterLogin(), the is_first_visit key is cleared from the session. Unless that is called, is_first_visit always stays “yes”.
Hopefully this helps someone else who is trying to optimize their store and yet breaks core functionality in the process.
This is indeed and excellent article. However, I’m having a hard time finding anything for “beginners” with Composer. Everything seems to assume a basic understanding of Composer. I know it’s installed, but I have no clue as to how it’s accessed and used. Hopefully you can point me in the general direction. Thanks
Generally I recommend the composer website itself https://getcomposer.org/. That’s where I learned most of my composer knowledge quite a few years ago. If you have some colleague who can teach you the basics of composer, it would of course be even more effective.
This is amazing.
Any chance of 2.2.7 and 2.2.8 update?
What are the drawbacks of this procedure?
I have written about the drawbacks in the article. Especially you need to test everything carefully as there might be undocumented dependencies.
Thanks to this article we have created the Magento-Lite Repository here https://github.com/shinesoftware/magento-lite for all who need a list of package to remove from the latest Magento.