Version constraints
When we require
a package in our composer.json
file, we also have to define a "version constraint." This instructs Composer on exactly what versions are acceptable to be installed.
The most flexible option is to specify *
as the version constraint, which means "anything." It will still respect the configured minimum stability but beyond that, anything goes. This is generally a terrible idea as things could change wildly from one version to the next when you update packages, breaking your application in weird and wonderful ways.
Instead, we always want to specify some kind of constraint. When we call composer
require
, Composer will calculate a constraint for us. You can see these in the composer.json
file we created in MyFirstProject:
"monolog/monolog": "^2.2", "php-di/php-di": "^6.3"
What Composer has used here is what is called the "Caret...