0
|
1 composer/semver
|
|
2 ===============
|
|
3
|
|
4 Semver library that offers utilities, version constraint parsing and validation.
|
|
5
|
|
6 Originally written as part of [composer/composer](https://github.com/composer/composer),
|
|
7 now extracted and made available as a stand-alone library.
|
|
8
|
|
9 [![Build Status](https://travis-ci.org/composer/semver.svg?branch=master)](https://travis-ci.org/composer/semver)
|
|
10
|
|
11
|
|
12 Installation
|
|
13 ------------
|
|
14
|
|
15 Install the latest version with:
|
|
16
|
|
17 ```bash
|
|
18 $ composer require composer/semver
|
|
19 ```
|
|
20
|
|
21
|
|
22 Requirements
|
|
23 ------------
|
|
24
|
|
25 * PHP 5.3.2 is required but using the latest version of PHP is highly recommended.
|
|
26
|
|
27
|
|
28 Version Comparison
|
|
29 ------------------
|
|
30
|
|
31 For details on how versions are compared, refer to the [Versions](https://getcomposer.org/doc/articles/versions.md)
|
|
32 article in the documentation section of the [getcomposer.org](https://getcomposer.org) website.
|
|
33
|
|
34
|
|
35 Basic usage
|
|
36 -----------
|
|
37
|
|
38 ### Comparator
|
|
39
|
|
40 The `Composer\Semver\Comparator` class provides the following methods for comparing versions:
|
|
41
|
|
42 * greaterThan($v1, $v2)
|
|
43 * greaterThanOrEqualTo($v1, $v2)
|
|
44 * lessThan($v1, $v2)
|
|
45 * lessThanOrEqualTo($v1, $v2)
|
|
46 * equalTo($v1, $v2)
|
|
47 * notEqualTo($v1, $v2)
|
|
48
|
|
49 Each function takes two version strings as arguments. For example:
|
|
50
|
|
51 ```php
|
|
52 use Composer\Semver\Comparator;
|
|
53
|
|
54 Comparator::greaterThan('1.25.0', '1.24.0'); // 1.25.0 > 1.24.0
|
|
55 ```
|
|
56
|
|
57 ### Semver
|
|
58
|
|
59 The `Composer\Semver\Semver` class provides the following methods:
|
|
60
|
|
61 * satisfies($version, $constraints)
|
|
62 * satisfiedBy(array $versions, $constraint)
|
|
63 * sort($versions)
|
|
64 * rsort($versions)
|
|
65
|
|
66
|
|
67 License
|
|
68 -------
|
|
69
|
|
70 composer/semver is licensed under the MIT License, see the LICENSE file for details.
|