0

I would like to know what the composer.json file is actually used for when I create a new module.

I know it's an optional file that can be created when I create a new module so why include it?

Take the magento/catalog composer.json file as an example, what is it doing?

{
    "name": "magento/module-catalog",
    "description": "N/A",
    "require": {
    "php": "~7.0.13|~7.1.0",
    "magento/module-store": "100.2.*",
    "magento/module-eav": "101.0.*",
    "magento/module-cms": "102.0.*",
    "magento/module-indexer": "100.2.*",
    "magento/module-customer": "101.0.*",
    "magento/module-theme": "100.2.*",
    "magento/module-checkout": "100.2.*",
    "magento/module-backend": "100.2.*",
    "magento/module-widget": "101.0.*",
    "magento/module-wishlist": "101.0.*",
    "magento/module-tax": "100.2.*",
    "magento/module-msrp": "100.2.*",
    "magento/module-catalog-inventory": "100.2.*",
    "magento/module-directory": "100.2.*",
    "magento/module-catalog-rule": "101.0.*",
    "magento/module-product-alert": "100.2.*",
    "magento/module-url-rewrite": "101.0.*",
    "magento/module-catalog-url-rewrite": "100.2.*",
    "magento/module-page-cache": "100.2.*",
    "magento/module-quote": "101.0.*",
    "magento/module-config": "101.0.*",
    "magento/module-media-storage": "100.2.*",
    "magento/framework": "101.0.*",
    "magento/module-ui": "101.0.*"
   },
   "suggest": {
    "magento/module-cookie": "100.2.*",
    "magento/module-sales": "101.0.*",
    "magento/module-catalog-sample-data": "Sample Data version:100.2.*"
  },
  "type": "magento2-module",
   "version": "102.0.5",
   "license": [
    "OSL-3.0",
    "AFL-3.0"
   ],
   "autoload": {
    "files": [
        "registration.php"
    ],
    "psr-4": {
        "Magento\\Catalog\\": ""
    }
}
}
2

Composer is a PHP dependency manager. Magento uses it to package component (module, metapackage i.e a set modules,theme, language etc). It defines the dependencies needed to run a package. For more information go to here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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