{"id":16986253,"url":"https://github.com/rayne/semantic-versioning.php","last_synced_at":"2025-04-15T07:44:55.069Z","repository":{"id":62533600,"uuid":"48456269","full_name":"Rayne/semantic-versioning.php","owner":"Rayne","description":"A tiny independent library for parsing and comparing semantic versions.","archived":false,"fork":false,"pushed_at":"2017-12-29T12:56:09.000Z","size":31,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T17:57:31.409Z","etag":null,"topics":["composer","composer-packages","php","php-library","semantic-versioning"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rayne.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-22T22:06:36.000Z","updated_at":"2023-05-11T00:11:43.000Z","dependencies_parsed_at":"2022-11-02T15:02:13.285Z","dependency_job_id":null,"html_url":"https://github.com/Rayne/semantic-versioning.php","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rayne%2Fsemantic-versioning.php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rayne%2Fsemantic-versioning.php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rayne%2Fsemantic-versioning.php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rayne%2Fsemantic-versioning.php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rayne","download_url":"https://codeload.github.com/Rayne/semantic-versioning.php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249031449,"owners_count":21201353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer","composer-packages","php","php-library","semantic-versioning"],"created_at":"2024-10-14T02:45:11.784Z","updated_at":"2025-04-15T07:44:55.054Z","avatar_url":"https://github.com/Rayne.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"#\tRayne\\SemanticVersioning\n\nA tiny independent library for parsing and comparing semantic versions which is compatible with [Semantic Versioning 2.0](http://semver.org).\n\n[![Latest Stable Version](https://poser.pugx.org/rayne/semantic-versioning/v/stable)](https://packagist.org/packages/rayne/semantic-versioning)\n[![Latest Unstable Version](https://poser.pugx.org/rayne/semantic-versioning/v/unstable)](https://packagist.org/packages/rayne/semantic-versioning)\n[![Build Status](https://travis-ci.org/Rayne/semantic-versioning.php.svg?branch=master)](https://travis-ci.org/Rayne/semantic-versioning.php)\n[![Code Coverage](https://scrutinizer-ci.com/g/Rayne/semantic-versioning.php/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Rayne/semantic-versioning.php/?branch=master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Rayne/semantic-versioning.php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Rayne/semantic-versioning.php/?branch=master)\n[![License](https://poser.pugx.org/rayne/semantic-versioning/license)](https://packagist.org/packages/rayne/semantic-versioning)\n\n##\tDependencies\n\n###\tProduction\n\n*\tPHP 5.6 or better\n\n###\tDevelopment\n\n*\tComposer\n*\tGit\n*\tPHPUnit\n\n##\tSetup\n\n[Download Composer](https://getcomposer.org/download) and install `rayne/semantic-versioning`.\n\n\tcomposer require rayne/semantic-versioning\n\n##\tTests\n\n1.\tClone the repository\n\n\t\tgit clone https://github.com/rayne/semantic-versioning.php.git\n\n2.\tInstall the development dependencies\n\n\t\tcomposer install --dev\n\n3.\tRun the tests\n \n\t\t./vendor/bin/phpunit\n\n##\tExamples\n\nThe library contains the following classes:\n\n*\t`InvalidVersionException`: Thrown by `SemanticVersion` on invalid input\n\n*\t`SemanticComparator`: The semantic versioning comparator for comparing `SemanticVersion` objects\n\n*\t`SemanticVersion`: The semantic versioning parser which throws a `RuntimeException` on invalid versions\n\nThe examples are part of the test suite.\nHave a look at the `tests` directory for more information.\n\n###\tInterpret semantic versions\n\n```php\nuse Rayne\\SemanticVersioning\\SemanticVersion;\n\n$version = new SemanticVersion('1.0.0-beta+exp.sha.5114f85');\n\nassert('1.0.0-beta+exp.sha.5114f85' === (string) $version);\nassert( 1                           === $version-\u003egetMajor());\nassert(   0                         === $version-\u003egetMinor());\nassert(     0                       === $version-\u003egetPatch());\nassert(      'beta'                 === $version-\u003egetPre());\nassert(           'exp.sha.5114f85' === $version-\u003egetMeta());\nassert('1.0.0-beta+exp.sha.5114f85' === $version-\u003egetVersion());\n\nassert(true  === $version-\u003eisMajorRelease());\nassert(false === $version-\u003eisMinorRelease());\nassert(false === $version-\u003eisPatchRelease());\nassert(true  === $version-\u003eisPreRelease());\n```\n\n###\tCompare semantic versions\n\n```php\nuse Rayne\\SemanticVersioning\\SemanticComparator;\nuse Rayne\\SemanticVersioning\\SemanticVersion;\n\n$comparator     = new SemanticComparator;\n\n$alpha          = new SemanticVersion('1.0.0-alpha');\n$candidate      = new SemanticVersion('1.0.0-rc.1');\n$candidate_meta = new SemanticVersion('1.0.0-rc.1+ci');\n$release        = new SemanticVersion('1.0.0');\n\n// $alpha \u003c $candidate\nassert($comparator($alpha, $candidate) \u003c 0);\nassert($comparator-\u003ecompare($alpha, $candidate) \u003c 0);\n\n// $candidate == $candidate_meta\nassert($comparator($candidate, $candidate_meta) == 0);\nassert($comparator-\u003ecompare($candidate, $candidate_meta) == 0);\n\n// $release \u003e $candidate\nassert($comparator($release, $candidate) \u003e 0);\nassert($comparator-\u003ecompare($release, $candidate) \u003e 0);\n```\n\n###\tSort semantic versions\n\n```php\nuse Rayne\\SemanticVersioning\\SemanticComparator;\nuse Rayne\\SemanticVersioning\\SemanticVersion;\n\n$versions = [\n\t$candidate = new SemanticVersion('1.0.0-rc.1'),\n\t$release   = new SemanticVersion('1.0.0'),\n\t$alpha     = new SemanticVersion('1.0.0-alpha'),\n];\n\n// Sort by semantic precedence.\nusort($versions, new SemanticComparator);\n\nassert($versions[0] === $alpha);\nassert($versions[1] === $candidate);\nassert($versions[2] === $release);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frayne%2Fsemantic-versioning.php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frayne%2Fsemantic-versioning.php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frayne%2Fsemantic-versioning.php/lists"}