I would like to know that why we create
compose.json and What is it use. Can someone briefly explain that to me?
company --module composer.json
Magento 2 uses Composer, a PHP dependency manager, to package components and product editions.
Composer is a dependency management for PHP and in Magento 2, the composer plays the role in gathering components and product editions. When using the Magento 2 composer, there is no requirement of storing all code of each component, and you only need to create composer.json file and declare the needed components in that file instead that. Immediately, the composer will auto-define and take the corresponding data of those components to run for your project.
The Magento composer.json file defines the name, requirements, version, and other basic information about the component. This file must be placed in the root directory of the module.
Composer reads a
composer.json file in Magento’s root directory to download third-party dependencies listed in the file.
The Component Manager uses the
composer.json file in an extension’s root directory to perform the following actions:
The Component Manager can update, uninstall, enable, or disable an extension if installed using Composer (including from Packagist, Magento Marketplace, or other source) and it has a
The Component Manager can still enable or disable an extension not installed using Composer (e.g. custom code) if it has a composer.json file.
Magento recommend you include composer.json in your component’s root directory even if you do not intend to distribute it to other merchants using Magento.