Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer. You can expect quick tips, links to interesting tutorials, opinions and packages. Want to learn the cool stuff? Then sign up now!

Tilde and caret version constraints in Composer

There are also some syntactic sugar operators like ~ (tilde) and ^ (caret).

  • ~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 defining backwards compatible version ranges.
  • ^4 means >=4.0.0,<5.0.0 which is the same as ~4 and 4.*.



Freek Van der Herten is a partner and developer at Spatie, an Antwerp based company that specializes in creating web apps with Laravel. After hours he writes about modern PHP and Laravel on this blog. When not coding he’s probably rehearsing with his kraut rock band. He loves waffles and butterflies.