How to Install a Specific Version of a Package Using Composer?

I want to install a specific version of a package in my PHP project using Composer. I have Composer installed on my system, but I’m not sure how to specify the version I want to install. Can someone please provide me with the command and syntax to install a specific version of a package using Composer? For example, I want to install version 2.1.0 of the example/package package.

To install a specific version of a package using Composer, you need to specify the package name followed by the version number. Here’s how you can do it:

composer require vendor/package:version

Replace vendor/package with the name of the package you want to install and version with the specific version number you want to install.

If you want to install version 2.1.0 of the example/package package, you would run the following command:

composer require example/package:2.1.0