Laravel Tutorials / updated: July 19, 2016

What are the asterisk, tilde, and caret used for in Composer?

In this Composer tutorial learn about the differences between all these characters:

Depending on your dependency manager you can define version constraints using wildcards (*), comparators like <=, logical operators (, often means AND and | means OR), etc… Using logical operators you can mix and match different version constraints to build even more complex ones. For example >=0.9.0,<0.11.0 means everything that matches 0.9.* and 0.10.*, but can also be noted as 0.9.* || 0.10.*. * ~4.1.3 means >=4.1.3,<4.2.0, * ~4.1 means >=4.1.0,<5.0.0 (most used), * ~0.4 means >=0.4.0,<1.0.0, * ~4 means >=4.0.0,<5.0.0. The caret sign is slightly different: * ^4.1.3 (most used) means >=4.1.3,<5.0.0, * ^4.1 means >=4.1.0,<5.0.0, same as ~4.1 but: * ^0.4 means >=0.4.0,<0.5.0, this is different from ~0.4 and is more useful for semver. * ^4 means >=4.0.0,<5.0.0 which is the same as ~4 and 4.*.

A little easier to remember than the php date format however this isn’t even all the options. The docs say you can also use a range and a hyphen range.

Laravel News Partners

Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.