Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install a specific version of package using Composer?

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?

like image 482
gdaras Avatar asked Dec 01 '16 15:12

gdaras


People also ask

How do I update a composer package to a specific 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.

How do I specify a version of a package?

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.

Does composer install update packages?

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.


2 Answers

composer require vendor/package:version

for example:

composer require refinery29/test-util:0.10.2

like image 129
alucic Avatar answered Sep 17 '22 02:09

alucic


Add double quotes to use caret operator in version number.

composer require middlewares/whoops "^0.4" 
like image 21
Yoann Kergall Avatar answered Sep 19 '22 02:09

Yoann Kergall