Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between "1.*" and "1.x" in composer require

Tags:

composer-php

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?

like image 872
Nick Carson Avatar asked Apr 29 '26 01:04

Nick Carson


1 Answers

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 *.

like image 103
Niels Keurentjes Avatar answered May 01 '26 19:05

Niels Keurentjes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!