Sunday, January 30, 2022

[FIXED] Difference between "1.*" and "1.x" in composer require

Issue

When requiring packages in composer.json file, what is the difference between:

"require": {
    "SomePackage": "1.*"
}

and

"require": {
    "SomePackage": "1.x"
}

or are they both the same thing?


Solution

From the source code:

325.   // match wildcard constraints
326.   if (preg_match('{^(\d+)(?:\.(\d+))?(?:\.(\d+))?\.[x*]$}', $constraint, $matches)) {
                                                         ^^

You can see in this regexp that x is indeed an undocumented alias to *.



Answered By - Niels Keurentjes

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.