How to "composer require" a Specific PHP Package Version?

When using the composer require command, you can specify the version for a package right after the package name, separated by a colon (:), like so:

composer require vendor/package:version

For example, to specify the exact version number for, let's suppose the designcise/bitframe package, you would do the following:

composer require designcise/bitframe:3.5.0

You can of course specify any version or constraints as you would in your composer.json files. For example, to specify a caret version range you would do the following:

composer require designcise/bitframe:^3.5

This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.