{"id":13616662,"url":"https://github.com/phar-io/version","last_synced_at":"2025-05-14T11:08:27.452Z","repository":{"id":37951892,"uuid":"75178811","full_name":"phar-io/version","owner":"phar-io","description":"Library for handling version information and constraints","archived":false,"fork":false,"pushed_at":"2024-01-31T22:47:27.000Z","size":94,"stargazers_count":7447,"open_issues_count":3,"forks_count":17,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-07T10:52:36.579Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://phar.io/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phar-io.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":["theseer"]}},"created_at":"2016-11-30T11:00:48.000Z","updated_at":"2025-05-06T08:14:35.000Z","dependencies_parsed_at":"2024-06-18T10:51:30.901Z","dependency_job_id":"7929debb-629e-4c3d-acba-7b4dd0bc66af","html_url":"https://github.com/phar-io/version","commit_stats":{"total_commits":92,"total_committers":13,"mean_commits":7.076923076923077,"dds":0.3804347826086957,"last_synced_commit":"4f7fd7836c6f332bb2933569e566a0d6c4cbed74"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phar-io%2Fversion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phar-io%2Fversion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phar-io%2Fversion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phar-io%2Fversion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phar-io","download_url":"https://codeload.github.com/phar-io/version/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254043221,"owners_count":22004912,"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":[],"created_at":"2024-08-01T20:01:31.598Z","updated_at":"2025-05-14T11:08:27.431Z","avatar_url":"https://github.com/phar-io.png","language":"PHP","funding_links":["https://github.com/sponsors/theseer"],"categories":["PHP","类库"],"sub_categories":["未归类"],"readme":"# Version\n\nLibrary for handling version information and constraints\n\n[![CI](https://github.com/phar-io/version/actions/workflows/ci.yml/badge.svg)](https://github.com/phar-io/version/actions/workflows/ci.yml)\n\n## Installation\n\nYou can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):\n\n    composer require phar-io/version\n\nIf you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:\n\n    composer require --dev phar-io/version\n\n## Version constraints\n\nA Version constraint describes a range of versions or a discrete version number. The format of version numbers follows the schema of [semantic versioning](http://semver.org): `\u003cmajor\u003e.\u003cminor\u003e.\u003cpatch\u003e`. A constraint might contain an operator that describes the range.\n\nBeside the typical mathematical operators like `\u003c=`, `\u003e=`, there are two special operators:\n\n*Caret operator*: `^1.0`\ncan be written as `\u003e=1.0.0 \u003c2.0.0` and read as »every Version within major version `1`«.\n\n*Tilde operator*: `~1.0.0`\ncan be written as `\u003e=1.0.0 \u003c1.1.0` and read as »every version within minor version `1.1`. The behavior of tilde operator depends on whether a patch level version is provided or not. If no patch level is provided, tilde operator behaves like the caret operator: `~1.0` is identical to `^1.0`.\n\n## Usage examples\n\nParsing version constraints and check discrete versions for compliance:\n\n```php\n\nuse PharIo\\Version\\Version;\nuse PharIo\\Version\\VersionConstraintParser;\n\n$parser = new VersionConstraintParser();\n$caret_constraint = $parser-\u003eparse( '^7.0' );\n\n$caret_constraint-\u003ecomplies( new Version( '7.0.17' ) ); // true\n$caret_constraint-\u003ecomplies( new Version( '7.1.0' ) ); // true\n$caret_constraint-\u003ecomplies( new Version( '6.4.34' ) ); // false\n\n$tilde_constraint = $parser-\u003eparse( '~1.1.0' );\n\n$tilde_constraint-\u003ecomplies( new Version( '1.1.4' ) ); // true\n$tilde_constraint-\u003ecomplies( new Version( '1.2.0' ) ); // false\n```\n\nAs of version 2.0.0, pre-release labels are supported and taken into account when comparing versions:\n\n```php\n\n$leftVersion = new PharIo\\Version\\Version('3.0.0-alpha.1');\n$rightVersion = new PharIo\\Version\\Version('3.0.0-alpha.2');\n\n$leftVersion-\u003eisGreaterThan($rightVersion); // false\n$rightVersion-\u003eisGreaterThan($leftVersion); // true\n\n``` \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphar-io%2Fversion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphar-io%2Fversion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphar-io%2Fversion/lists"}