I built an extension for Magento 2 and now I want to package it using the following guide: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/package/package_module.html

There is a sample composer.json: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/package/package_module.html#sample-composerjson-file

I am wondering what is really necessary to state in the require field as Magento more or less only works correctly if all modules are enabled. There are Magento modules which depend on each other, for example Magento will certainly use the magento/framework package. So can I omit that in my own composer.json as I can assume the framework is certainly available? For my first composer.json I looked at all the constructors and use clauses in my extension's code and these are all modules which are used. But is this amount of required packages really necessary?

"require": {
    "php": "~5.5.0|~5.6.0|~7.0.0",
    "magento/module-backend": "100.0.*",
    "magento/module-customer": "100.0.*",
    "magento/module-product": "100.0.*",
    "magento/module-wishlist": "100.0.*",
    "magento/module-cms": "100.0.*",
    "magento/module-catalog": "100.0.*",
    "magento/module-eav": "100.0.*",
    "magento/module-store": "100.0.*",
    "magento/module-ui": "100.0.*",
    "magento/framework": "100.0.*"


2 Answers 2


If you are using classes of all these packages directly then yes I would include them in your require section, as in, if your code needs to be able to run with what is in the require section.

Dependencies can change over time, so for example if you removed module/wishlist because you know that module/catalog uses it at the moment (I didn't confirm) but Magento might be able to decouple these in the future which would then break your module because of the above assumption that this will stay this way.


The reason for other module-dependencies to be specified in composer.json: it is useful when modules are to be enable/disabled or completely removed. For example, your module depends on cms, and if you attempt to disable cms, it will throw and error since your module depends on it, and is active.

For sake of modularity, magento/framework is required, if your extension's code depends on it, even though this can't be disabled.

There is an easier way to check, if you depend on other modules; you can run these dependency checking tools.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.