install specific version of composer code example

Example 1: composer require with version

composer require vendor/package:version

composer require refinery29/test-util:0.10.2

Example 2: install composer

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '795f976fe0ebd8b75f26a6dd68f78fd3453ce79f32ecb33e7fd087d39bfeb978342fb73ac986cd4f54edd0dc902601dc') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Example 3: composer mac

php composer-setup.php --install-dir=bin --filename=composer

Example 4: composer install

getcomposer.org

Example 5: composer require specific version

composer require vendor/package:version

Example 6: composer install package with specific version

composer require PACKAGE_NAME "PACKAGE_VERSION"