composer create-project --repository-url=https://repo.magento.com/ code example
Example: install magento 2 using composer
1
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <install-directory-name>