{"id":17061812,"url":"https://github.com/phlak/semver","last_synced_at":"2025-04-14T08:52:57.377Z","repository":{"id":9357543,"uuid":"61848260","full_name":"PHLAK/SemVer","owner":"PHLAK","description":"Semantic versioning helper library for PHP","archived":false,"fork":false,"pushed_at":"2024-12-11T16:31:37.000Z","size":199,"stargazers_count":178,"open_issues_count":1,"forks_count":16,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-07T01:10:00.520Z","etag":null,"topics":["php","semantic-versioning","semver","versioning"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/phlak/semver","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/PHLAK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"PHLAK","patreon":"PHLAK","custom":"https://paypal.me/ChrisKankiewicz"}},"created_at":"2016-06-24T01:37:58.000Z","updated_at":"2025-03-25T10:29:45.000Z","dependencies_parsed_at":"2024-12-06T14:02:37.706Z","dependency_job_id":"12c029d5-57e7-412d-88f6-da35f59d16e3","html_url":"https://github.com/PHLAK/SemVer","commit_stats":{"total_commits":128,"total_committers":8,"mean_commits":16.0,"dds":0.1171875,"last_synced_commit":"1816dfb119207c7cde08ae32e57d1ab353614a81"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHLAK%2FSemVer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHLAK%2FSemVer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHLAK%2FSemVer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHLAK%2FSemVer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PHLAK","download_url":"https://codeload.github.com/PHLAK/SemVer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248852078,"owners_count":21171839,"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":["php","semantic-versioning","semver","versioning"],"created_at":"2024-10-14T10:48:16.374Z","updated_at":"2025-04-14T08:52:57.353Z","avatar_url":"https://github.com/PHLAK.png","language":"PHP","funding_links":["https://github.com/sponsors/PHLAK","https://patreon.com/PHLAK","https://paypal.me/ChrisKankiewicz"],"categories":[],"sub_categories":[],"readme":"SemVer\n======\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"semver.png\" alt=\"SemVer\" width=\"50%\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"http://semver.org\"\u003eSemantic versioning\u003c/a\u003e helper library\n  • Created by \u003ca href=\"https://www.ChrisKankiewicz.com\"\u003eChris Kankiewicz\u003c/a\u003e (\u003ca href=\"https://bsky.app/profile/phlak.dev\"\u003e@phlak.dev\u003c/a\u003e)\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/PHLAK/SemVer/discussions\"\u003e\u003cimg src=\"https://img.shields.io/badge/Join_the-Community-7b16ff.svg?style=for-the-badge\" alt=\"Join our Community\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/users/PHLAK/sponsorship\"\u003e\u003cimg src=\"https://img.shields.io/badge/Become_a-Sponsor-cc4195.svg?style=for-the-badge\" alt=\"Become a Sponsor\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://paypal.me/ChrisKankiewicz\"\u003e\u003cimg src=\"https://img.shields.io/badge/Make_a-Donation-006bb6.svg?style=for-the-badge\" alt=\"One-time Donation\"\u003e\u003c/a\u003e\n    \u003cbr\u003e\n    \u003ca href=\"https://packagist.org/packages/PHLAK/SemVer\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/PHLAK/SemVer.svg?style=flat-square\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/PHLAK/SemVer\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/PHLAK/SemVer.svg?style=flat-square\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/PHLAK/SemVer\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/PHLAK/SemVer.svg?style=flat-square\" alt=\"License\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/PHLAK/SemVer/actions\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/PHLAK/SemVer/test-suite.yaml?style=flat-square\u0026label=tests\" alt=\"Tests Status\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\nRequirements\n------------\n\n  - [PHP](https://php.net) \u003e= 8.1\n\nInstallation\n------------\n\n```bash\ncomposer require phlak/semver\n```\n\nInitializing\n------------\n\n```php\nuse PHLAK\\SemVer;\n\n$version = new SemVer\\Version(); // Initilializes to '0.1.0'\n```\n\nOr initialize with a custom version by passing a version string on creation.\nAccepts any valid semantic version string with or without a preceding `v`.\n\n```php\n$version = new SemVer\\Version('v1.2.3-alpha.5+sha.8d31ff4');\n```\n\nOr parse an incomple version string with the static `Version::parse()` constructor.\n\n```php\n$version = SemVer\\Version::parse('v1')   // Initializes to '1.0.0'\n$version = SemVer\\Version::parse('v1.2') // Initializes to '1.2.0'\n```\n\nUsage\n-----\n\n#### Retrieve the version or individual values\n\n```php\n$version = new SemVer\\Version('v1.2.3-beta.4+007');\n\necho $version;             // '1.2.3-beta.4+007'\necho $version-\u003emajor;      // 1\necho $version-\u003eminor;      // 2\necho $version-\u003epatch;      // 3\necho $version-\u003epreRelease; // 'beta.4'\necho $version-\u003ebuild;      // '007'\n```\n\n#### Increment the version\n\n```php\n$version = new SemVer\\Version('v1.2.3');\n\n$version-\u003eincrementMajor();      // v1.2.3 -\u003e v2.0.0\n$version-\u003eincrementMinor();      // v1.2.3 -\u003e v1.3.0\n$version-\u003eincrementPatch();      // v1.2.3 -\u003e v1.2.4\n$version-\u003eincrementPreRelease(); // v1.2.3-alpha.5 -\u003e v1.2.3-alpha.6\n```\n\n#### Set (override) the version or individual values\n\n```php\n$version = new SemVer\\Version();\n\n$version-\u003esetVersion('v1.2.3');  // v1.2.3\n$version-\u003esetMajor(3);           // v1.2.3 -\u003e v3.0.0\n$version-\u003esetMinor(5);           // v1.2.3 -\u003e v1.5.0\n$version-\u003esetPatch(7);           // v1.2.3 -\u003e 1.2.7\n$version-\u003esetPreRelease('rc.2'); // v1.2.3 -\u003e v1.2.3-rc.2\n$version-\u003esetBuild('007');       // v1.2.3 -\u003e v1.2.3+007\n```\n\n#### Clear pre-release / build values\n\n```php\n$version-\u003esetPreRelease(null); // v1.2.3-rc.2 -\u003e v1.2.3\n$version-\u003esetBuild(null);      // v1.2.3+007 -\u003e v1.2.3\n```\n\n\n#### Check for pre-release / build values\n\n```php\n$version-\u003eisPreRelease();\n$version-\u003ehasBuild();\n```\n\n#### Compare two SemVer objects\n\n```php\n$version1 = new SemVer\\Version('v1.2.3');\n$version2 = new SemVer\\Version('v3.2.1');\n\n$version1-\u003egt($version2);  // false\n$version1-\u003elt($version2);  // true\n$version1-\u003eeq($version2);  // false\n$version1-\u003eneq($version2); // true\n$version1-\u003egte($version2); // false\n$version1-\u003elte($version2); // true\n```\n\n##### Limit comparison to the major version only\n\nIgnores the minor, patch and pre-release versions completely\n\n```php\n$version1 = new SemVer\\Version('v1.2.3-alpha.4');\n$version2 = new SemVer\\Version('v1.3.4-alpha.5');\n\n$version1-\u003egt($version2, Compare::MAJOR);  // false\n$version1-\u003elt($version2, Compare::MAJOR);  // false\n$version1-\u003eeq($version2, Compare::MAJOR);  // true\n$version1-\u003eneq($version2, Compare::MAJOR); // false\n$version1-\u003egte($version2, Compare::MAJOR); // true\n$version1-\u003elte($version2, Compare::MAJOR); // true\n```\n\n##### Limit comparison to the major and minor versions only\n\nIgnores the patch and pre-release versions completely\n\n```php\n$version1 = new SemVer\\Version('v1.2.3-alpha.4');\n$version2 = new SemVer\\Version('v1.2.4-alpha.5');\n\n$version1-\u003egt($version2, Compare::MINOR);  // false\n$version1-\u003elt($version2, Compare::MINOR);  // false\n$version1-\u003eeq($version2, Compare::MINOR);  // true\n$version1-\u003eneq($version2, Compare::MINOR); // false\n$version1-\u003egte($version2, Compare::MINOR); // true\n$version1-\u003elte($version2, Compare::MINOR); // true\n```\n\n##### Limit comparison to the major, minor and patch versions only\n\nIgnores the pre-release version completely\n\n```php\n$version1 = new SemVer\\Version('v1.2.3-alpha.4');\n$version2 = new SemVer\\Version('v1.2.3-alpha.5');\n\n$version1-\u003egt($version2, Compare::PATCH);  // false\n$version1-\u003elt($version2, Compare::PATCH);  // false\n$version1-\u003eeq($version2, Compare::PATCH);  // true\n$version1-\u003eneq($version2, Compare::PATCH); // false\n$version1-\u003egte($version2, Compare::PATCH); // true\n$version1-\u003elte($version2, Compare::PATCH); // true\n```\n\nTroubleshooting\n---------------\n\nFor general help and support join our [GitHub Discussions](https://github.com/PHLAK/SemVer/discussions) or reach out on [Bluesky](https://bsky.app/profile/phlak.dev).\n\nPlease report bugs to the [GitHub Issue Tracker](https://github.com/PHLAK/SemVer/issues).\n\nCopyright\n---------\n\nThis project is liscensed under the [MIT License](https://github.com/PHLAK/SemVer/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphlak%2Fsemver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphlak%2Fsemver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphlak%2Fsemver/lists"}