Reputation: 127
Can any body explain me the difference between ^1.0 and ~1.0
"miserenkov/yii2-phone-validator": "^1.0"
and
"udokmeci/yii2-phone-validator" : "~1.0"
Thanks
Upvotes: 1
Views: 505
Reputation: 52862
These are what's called "Next Significant Release Operators".
The ~ operator is best explained by example: ~1.2 is equivalent to >=1.2 <2.0.0, while ~1.2.3 is equivalent to >=1.2.3 <1.3.0.
.. while ^ is slightly more permissible:
The ^ operator behaves very similarly but it sticks closer to semantic versioning, and will always allow non-breaking updates. For example ^1.2.3 is equivalent to >=1.2.3 <2.0.0
Updating ~1.2.3
would not upgrade to anything else than 1.2.x
, while ^1.2.3
could update to anything newer than 1.2.3
, all the way up to 2.0.0
.
In your case they should behave the same.
Upvotes: 4
Reputation: 14
in node "^1.0" always updates to the last version and "~ 1.0" will keep the current version.
Hope this helps!
Upvotes: 0
Reputation: 465
from the documentation: https://getcomposer.org/doc/articles/versions.md
Caret Version Range (^)#
The ^ operator behaves very similarly but it sticks closer to semantic versioning, and will always allow non-breaking updates.
For example ^1.2.3 is equivalent to >=1.2.3 <2.0.0 as none of the releases until 2.0 should break backwards compatibility.
For pre-1.0 versions it also acts with safety in mind and treats ^0.3 as >=0.3.0 <0.4.0.
Tilde Version Range (~)#
The ~ operator is best explained by example: ~1.2 is equivalent to >=1.2 <2.0.0, while ~1.2.3 is equivalent to >=1.2.3 <1.3.0.
As you can see it is mostly useful for projects respecting semantic versioning.
A common usage would be to mark the minimum minor version you depend on, like ~1.2 (which allows anything up to, but not including, 2.0).
Since in theory there should be no backwards compatibility breaks until 2.0, that works well.
Another way of looking at it is that using ~ specifies a minimum version, but allows the last digit specified to go up.
Upvotes: 0