'what's the purpose of composer's `require` command

Here is the definitions from the docs:

The require command adds new packages to the composer.json file from the current directory. If no file exists one will be created on the fly. After adding/changing the requirements, the modified requirements will be installed or updated.

If you do not want to choose requirements interactively, you can just pass them to the command.

I can't seem to understand the purpose of the require command and the difference from install. Can you elaborate on that?

And here is the example of using the command:

composer global require "fxp/composer-asset-plugin:~1.0.3"

Can you tell me what's the difference from:

composer global install "fxp/composer-asset-plugin:~1.0.3"


Solution 1:[1]

composer require->It will write the modules in composer.json file and install the module.

composer install->It will install the modules which are already present in the composer.json file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1