Magento 2 7/7/2024

Make Magento 2 small again

With version 2.3.0, Magento includes about 200 internal PHP packages (in the "magento" namespace) plus more than a hundred external PHP packages. These numbers have grown a lot in the last few releases, especially with several packages for the GraphQL integration and for the Multi Source Inventory. Since the average Magento 2 project doesn't need all those modules, wouldn't it be great to get rid of some unused modules?

I have written about how you can remove unused core modules before, including suggestions on what modules can be removed in Magento 2.2. At the recent Magento Hackathon in Bremen, Germany, one of the groups chose the topic "Make Magento small again" with the goal to reduce the number of dependencies between modules in order to be able to remove as many modules as possible.

Benefits of removing core modules

  • Less code means less maintenance work
  • Removed code is debugged code
  • Fewer security risks
  • Magento becomes faster with certain modules disabled (especially the Magento_Swatches module, see our blog post about performance improvements)

Risks of removing core modules

  • Dependencies may not be declared correctly, so you might actually remove code which is needed by another module.
  • You might need some of the removed functionality as it's not always clear which module contains which functionalities.

The Approach

It's preferred to remove modules via composer. Add a block as follows to your composer.json file:

    "replace": {
        "magento/module-dhl": "*",
        "magento/module-fedex": "*",
        "magento/module-marketplace": "*",
        "magento/module-multishipping": "*"
    },

After that, call composer update. The modules will be removed from the code base.

Ideally, you remove modules before installing Magento in your project. Otherwise, the installation will create some module specific tables in your database which will be obsolete after removing the corresponding modules.

Selection of modules

It's up to you which modules to remove. Here, we present a suggestion, but using it is on your own risk. Of course, you can re-add the modules you need in your project. For example:

  • If you use Swatches, enable magento/module-swatches and magento/module-swatches-layered-navigation.
  • If you'd like to use the Multi Source Inventory (MSI), don't remove the modules starting with magento/module-inventory.
  • If you use ImportExport for your interfaces, don't remove magento/module-*-import-export.

Suggestion for Magento 2.3.0:

    "replace": {
        "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-swagger-webapi-async": "*",
        "magento/module-swatches": "*",
        "magento/module-swatches-layered-navigation": "*",
        "magento/module-google-optimizer": "*",
        "magento/module-ups": "*",
        "magento/module-usps": "*",
        "magento/module-braintree": "*",
        "magento/module-signifyd": "*",
        "magento/module-release-notification": "*",
        "magento/module-new-relic-reporting": "*",
        "magento/module-version": "*",

        "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": "*",

        "magento/module-bundle-graph-ql": "*",
        "magento/module-catalog-graph-ql": "*",
        "magento/module-catalog-inventory-graph-ql": "*",
        "magento/module-catalog-url-rewrite-graph-ql": "*",
        "magento/module-cms-graph-ql": "*",
        "magento/module-cms-url-rewrite-graph-ql": "*",
        "magento/module-inventory-graph-ql": "*",
        "magento/module-configurable-product-graph-ql": "*",
        "magento/module-customer-graph-ql": "*",
        "magento/module-downloadable-graph-ql": "*",
        "magento/module-eav-graph-ql": "*",
        "magento/module-graph-ql": "*",
        "magento/module-grouped-product-graph-ql": "*",
        "magento/module-quote-graph-ql": "*",
        "magento/module-store-graph-ql": "*",
        "magento/module-swatches-graph-ql": "*",
        "magento/module-tax-graph-ql": "*",
        "magento/module-url-rewrite-graph-ql": "*",
        "magento/module-weee-graph-ql": "*",

        "magento/module-advanced-pricing-import-export": "*",
        "magento/module-bundle-import-export": "*",
        "magento/module-configurable-import-export": "*",
        "magento/module-customer-import-export": "*",
        "magento/module-downloadable-import-export": "*",
        "magento/module-grouped-import-export": "*",
        "magento/module-tax-import-export": "*",

        "magento/module-inventory": "*",
        "magento/module-inventory-admin-ui": "*",
        "magento/module-inventory-api": "*",
        "magento/module-inventory-bundle-product": "*",
        "magento/module-inventory-bundle-product-admin-ui": "*",
        "magento/module-inventory-cache": "*",
        "magento/module-inventory-catalog": "*",
        "magento/module-inventory-catalog-admin-ui": "*",
        "magento/module-inventory-catalog-api": "*",
        "magento/module-inventory-catalog-search": "*",
        "magento/module-inventory-configurable-product": "*",
        "magento/module-inventory-configurable-product-admin-ui": "*",
        "magento/module-inventory-configurable-product-indexer": "*",
        "magento/module-inventory-configuration": "*",
        "magento/module-inventory-configuration-api": "*",

        "magento/module-inventory-elasticsearch": "*",
        "magento/module-inventory-grouped-product": "*",
        "magento/module-inventory-grouped-product-admin-ui": "*",
        "magento/module-inventory-grouped-product-indexer": "*",
        "magento/module-inventory-import-export": "*",
        "magento/module-inventory-indexer": "*",
        "magento/module-inventory-low-quantity-notification": "*",
        "magento/module-inventory-low-quantity-notification-admin-ui": "*",
        "magento/module-inventory-low-quantity-notification-api": "*",
        "magento/module-inventory-multi-dimensional-indexer-api": "*",
        "magento/module-inventory-product-alert": "*",
        "magento/module-inventory-reservations": "*",
        "magento/module-inventory-reservations-api": "*",
        "magento/module-inventory-sales": "*",
        "magento/module-inventory-sales-admin-ui": "*",
        "magento/module-inventory-sales-api": "*",
        "magento/module-inventory-sales-frontend-ui": "*",
        "magento/module-inventory-shipping": "*",
        "magento/module-inventory-shipping-admin-ui": "*",
        "magento/module-inventory-source-deduction-api": "*",
        "magento/module-inventory-source-selection": "*",
        "magento/module-inventory-source-selection-api": "*",
        "magento/module-inventory-distance-based-source-selection": "*",
        "temando/module-shipping-m2": "*",
        "dotmailer/dotmailer-magento2-extension": "*",
        "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": "*",
        "vertex/sdk": "*"
    },

Please look through the list in detail before using it. There are no declared dependencies from any leftover core modules to the modules which are suggested to remove here, but there are dependencies between these removed modules. So if you re-add selected modules, you might need to re-add their dependencies too. Have a look at the module's composer.json if you are unsure about their dependencies.

Work in Progress

If you look at the list above, you can see that two modules are not included:

  • magento/module-import-export
  • magento/module-catalog-import-export

That is because there are dependencies declared from the Magento_CatalogUrlRewrite module to those two - dependencies which shouldn't be there in my opinion, because the Magento_CatalogUrlRewrite module will work flawlessly even without the ImportExport modules. It just adds two Observers which will never be instantiated if the ImportExport modules are not available. I have created a Pull Request to Magento about this issue - let's see what the core engineers' opinion is on this case.

Conclusion

If you don't need them, you can remove up to half of the Magento 2 core modules and most external Magento 2 modules. But please take care before and during the removal - some of the code might actually be used, so test it thoroughly. Using the above suggestions is at your own risk.

Update May 2019

We removed some modules which have to do with message queues from the list as they are reported to cause problems with the REST API. Thanks Oleksandr Lyzun for reporting!