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:

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:

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:

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:

Update for Magento 2.3

There is a seperate blog post about which modules can be removed from Magento 2.3.


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.

Andreas von Studnitz

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.

More Information · Twitter · GitHub · LinkedIn