Summary: In this post, We are going to learn the meaning of tilde (~), caret (^), wildcard ( * ) in composer.json file. When we install the composer you can see a file name composer.json is created. When we just open it we can see some sign near to version like tilde (~), caret (^) and wildcard ( *). For example, I show you
yii2 json file below:
"yiisoft/yii2-swiftmailer":"~2.0.0 || ~2.1.0"
Composer.json file different for different dependency.
While we install any dependency through the composer we need to define which version of any dependency we are going to use that why we need the separate type symbol to define the versions. With the help of these symbols, you can define that which version of any dependency you want to use. You can also use logic operators (
, often means AND and
| means OR) to define the range of version. Even you can use some complex condition for the version by using comparators, for example, >=0.8.0,<0.10.0
Means of this is your version greater than 0.8.* and less than 0.9.* (wildcard ( * ) means value lies between 0 to 9)
Let’s take a look of the tilde (~) and caret (^) symbol.
The caret symbol is a bit different:
That’s all ??
Hope you understand still have any question you can comment below.