Using Composer to produce websites was implemented in Drupal 8 as a recommended approach to maintain an enterprises code. The primary function of Composer is to manage PHP libraries and dependencies in an organised and coherent fashion.
The composer website describes their tool following the way:
Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
Amidst the creation, Drupal 8, various PHP community methodologies were selected, allowing Drupal modules to be installed and supported using Composer. Below are some commonly used Composer actions from the command-line that improve the development of a Drupal website
New installation of Drupal using composer
If you need to install Drupal the default version using Composer use the command beneath.
$ composer create-project drupal/recommended-project <installation_directory>
Pin the installation Drupal 8 to a certain version by using the claret and then the number the team needs
$ composer create-project drupal/recommended-project:^8.9.3 <installation_directory>
Installation of a Drupal contributed module is relative easy
$ composer require drupal/devel