I am creating a module in Magento 2. Now I am writing composer.json. Here I write supporting PHP version

"require": {
    "php": "~5.6.0|^7.0.0",

How do I write my module will be supported by Magento version greater than 2.1, not support by 2.0

I found

 "magento/framework": "^102.0.0",
"magento/module-backend": "^101.0.0"

What is the meaning of above lines . is it the version of Magento? what are 102.0.0 means?

1 Answer 1


As far as I know, you cannot specify a version for the 'parent' project in general with composer. The version of a composer package (here the Magento shop) is even optional, so you could not reliably depend on it:

The version of the package. In most cases this is not required and should be omitted

And a Magento installation is consisting of Magento modules. And these modules have their own versions. Though it would desirable to tell composer "Hey, this module can only be used with version X of Magento", you actually have to make the extension dependent on the other Magento extensions, which seems to have their own versioning scheme (with versions > 100). And probably this is what you actually want, since (I guess) your module code really depends on those Magento core modules.

In the composer.json file of my installation (2.3.1) I found a required package "magento/product-community-edition":"2.3.1". It would be tempting to make the module dependent on this, however, this is discouraged:

Do not specify a dependency on meta packages (e.g. product-community-edition).

So it seems you should make your module open for different versions or specify the requirements in a readme file.

  • Regarding "magento/product-community-edition" I created an issue for the docs.
    – robsch
    Commented Apr 17, 2019 at 21:26

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.