I am trying to install a specific version of a package using Composer. I tried composer install
and composer require
but they are installing the latest version of the package. What if I want an older version?
If you were hoping to switch to a specific version and check-in your composer. lock file, you can, but you'd have to use composer require and then revert the change to composer. json afterwards.
Using either a caret ( ^ ) or a tilde ( ~ ) we can specify the latest minor or patch version, respectively. This way you can specify a compatible package version, but still get the latest.
composer update will update our dependencies as they are specified in composer. json . Supposing we have actually installed the 2.0. 1 version of the package, running composer update will cause an upgrade of this package (for example to 2.0.
composer require vendor/package:version
for example:
composer require refinery29/test-util:0.10.2
Add double quotes to use caret operator in version number.
composer require middlewares/whoops "^0.4"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With