{"id":18584961,"url":"https://github.com/php-mod/version","last_synced_at":"2025-04-10T12:30:59.904Z","repository":{"id":22055838,"uuid":"25384673","full_name":"php-mod/version","owner":"php-mod","description":"Versions and Constraints for PHP","archived":false,"fork":false,"pushed_at":"2019-11-14T17:15:35.000Z","size":57,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"2.x","last_synced_at":"2025-03-24T21:22:23.096Z","etag":null,"topics":[],"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/php-mod.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-18T02:23:21.000Z","updated_at":"2023-11-11T04:59:33.000Z","dependencies_parsed_at":"2022-08-20T18:40:35.919Z","dependency_job_id":null,"html_url":"https://github.com/php-mod/version","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-mod%2Fversion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-mod%2Fversion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-mod%2Fversion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-mod%2Fversion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-mod","download_url":"https://codeload.github.com/php-mod/version/tar.gz/refs/heads/2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247968249,"owners_count":21025797,"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-11-07T00:29:33.953Z","updated_at":"2025-04-10T12:30:59.615Z","avatar_url":"https://github.com/php-mod.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Versions and Constraints for PHP\n================================\n\nThis library parse versions, \nE.x.:\n\u003ccode\u003e1.0.0\u003c/code\u003e\n\u003ccode\u003e1.0.2-stable\u003c/code\u003e\n\u003ccode\u003e1.0.20-alpha2\u003c/code\u003e.\nIt can parse constraints (like Composer versions),\nE.x.:\n\u003ccode\u003e\u003e=1.0 \u003e=1.0,\u003c2.0 \u003e=1.0,\u003c1.1 | \u003e=1.2\u003c/code\u003e,\n\u003ccode\u003e1.0.*\u003c/code\u003e,\n\u003ccode\u003e~1.2\u003c/code\u003e.\n\nThe goal of that is to let you check if a version matches a constraint,\nor to check if a constraint is a subset of another constraint.\n\nAll that is done to let us select which version is compatible with a user constraints.\n\nIt works with the same rules of Composer versioning.\n\n### Sorting\nIn order to use standard PHP sorting there is a helper class 'Compare' to use it with a sort you will need to do this;\n\n```php\nuse Version\\Version;\nuse Version\\Compare;\n\n$vers = array();\n$vers[] = Version::parse('1.1.1d1');\n$vers[] = '1.1.1';\n\n$obj = new Compare();\nusort( $vers, array( $obj, 'compare' ) );\n```\n\nThe above should allow any normal PHP sort to be instigated with very little effort.\n\n**Note**: You should see that it will handle a string or a Version object as the variable to sort automatically.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-mod%2Fversion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-mod%2Fversion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-mod%2Fversion/lists"}