Composer is a tool that handles dependency management in PHP. It is not a package manager like Yum and Apt on Linux systems are. Though it deals with libraries (packages), it does so on a per-project level. It does not install anything globally. Composer is a multiplatform tool. Therefore, it runs equally well on Windows, Linux, and OS X.
Installing Composer on a machine is as simple as running the installer in the project directory by using the following command:
curl -sS https://getcomposer.org/installer | php
More information about the installation of Composer can be found on its official website, which can be viewed by visiting https://getcomposer.org.
Composer is used to fetch Magento and the third-party components that it uses. As seen in the previous chapter, the following composer command is what pulls everything into the specified directory:
Once Magento is downloaded and installed, there are numerous composer.json files that can be found in its directory. Assuming <installation directory name> is magento2, if we were to do a quick search executing command such as find magento2/ -name 'composer.json', that would yield over 100 composer.json files. Some of these files are (partially) listed here:
Composer's JSON file follows a certain schema. You will find a detailed documentation of this schema at https://getcomposer.org/doc/04-schema.md. Applying to the schema ensures validity of the composer file. We can see that all the listed keys such as name, description, require, config, and so on, are defined by the schema.
Let's take a look at the individual module's composer.json file. One of the simpler modules with the least amount of dependencies is the Contact module with its vendor/magento/module-contact/composer.json content, which looks like this:
You will see that the modules define dependencies on the PHP version and other modules. Furthermore, you will see the use of PSR-4 for autoloading and the direct loading of the registration.php file.
Next, let's take a look at the contents of vendor/magento/language-en_us/composer.json from the en_us language module: