Using a stable version of a package, whatever the major version with composer

Published on 2021-10-03 • Modified on 2021-10-03

This snippet shows how to use a stable version of a package, whatever the major version with composer. We generally use major requirements when using a library, like ^2.0, which tells composer to update to any version below to the next major version, which is 3.0.0. But, for development tools, sometimes, what we want is just the last stable version because it won't break our application. At worst, it could break the CI. The great thing is that if our app our the CI is broken, we know that a new major was released for this package. If all is OK, then we automatically used a new major version without even noticing it. If we have problems, we can fix them or to stick to the last major version we used before. At least, we know that we have an upgrade to do. So, in my current configuration, I put it on friendsofphp/php-cs-fixer, which is an excellent candidate to use this @stable requirement.


{ "this is an extract of the composer.json file" },
{
    "require": {
        "friendsofphp/php-cs-fixer": "@stable",
    }
}

 More on Stackoverflow   Read the doc  More on the web  Random snippet