As you know Composer is a great tool to manage packages and their dependencies in PHP, while in Drupal 8.8 is going to more composer compatible, you can find composer cheatsheet in the following.
Downloads and installs all the libraries and dependencies outlined in the composer.lock file. If the file does not exist it will look for composer.json and do the same, creating a composer.lock file.
composer install --dry-run
Simulates the install without installing anything.
This command doesn’t change any file. If
composer.lockis not present, it will create it.
composer.lockshould always be committed to the repository. It has all the information needed to bring the local dependencies to the last committed state. If that file is modified on the repository, you will need to run
composer installagain after fetching the changes to update your local dependencies to those on that file
composer require vendor/package ## or in a short way composer req vendor/package
requiresection and installs it
composer require vendor/package --dev
Adds package from vendor to composer.json’s require-dev section and installs it. This command changes both the composer.json and composer.lock files.
composer remove vendor/package
Removes vendor/package from composer.json and uninstalls it This command changes both the composer.json and composer.lock files.
Updates all packages
composer update --with-dependencies
Updates all packages and its dependencies
composer update vendor/package
Updates a certain
composer update vendor/*
Updates all packages from
composer update --lock
Updates composer.lock hash without updating any packages This command changes only the composer.lock file.
PS: the all above comments will work to install drupal , just keep in mind in all drupal modules, vendor=drupal, it means if you want to install a module, just change vendor name in above command wit drupal.for example
I want to install Nothing module, the url of the module is https://www.drupal.org/project/nothing so the command for install it is
composer req drupal/nothing
Development with composer and packages is much much easier than legacy code.