{"id":17797378,"url":"https://github.com/steevanb/php-version-comparator","last_synced_at":"2025-04-02T03:21:02.254Z","repository":{"id":57059382,"uuid":"420435276","full_name":"steevanb/php-version-comparator","owner":"steevanb","description":"Compare PHP version easier than with version_compare()","archived":false,"fork":false,"pushed_at":"2021-10-23T22:57:37.000Z","size":54,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-12T02:47:35.073Z","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/steevanb.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":"2021-10-23T14:28:30.000Z","updated_at":"2021-10-23T22:57:38.000Z","dependencies_parsed_at":"2022-08-24T07:40:07.884Z","dependency_job_id":null,"html_url":"https://github.com/steevanb/php-version-comparator","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steevanb%2Fphp-version-comparator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steevanb%2Fphp-version-comparator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steevanb%2Fphp-version-comparator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steevanb%2Fphp-version-comparator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/steevanb","download_url":"https://codeload.github.com/steevanb/php-version-comparator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246747769,"owners_count":20827213,"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-10-27T11:55:34.713Z","updated_at":"2025-04-02T03:21:02.235Z","avatar_url":"https://github.com/steevanb.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Version](https://img.shields.io/badge/version-0.2.0-4B9081.svg)](https://github.com/steevanb/php-version-comparator/tree/0.2.0)\n[![License](https://poser.pugx.org/steevanb/version-comparator/license)](https://github.com/steevanb/php-version-comparator/blob/master/LICENSE)\n[![PHP](https://img.shields.io/badge/php-^5.3||^7.0||^8.0-blue.svg)](https://php.net)\n![Lines](https://img.shields.io/badge/code%20lines-4,561-blue.svg)\n![Downloads](https://poser.pugx.org/steevanb/version-comparator/downloads)\n\n[![CI](https://github.com/steevanb/php-version-comparator/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/steevanb/php-version-comparator/actions/workflows/ci.yml)\n![Tests](https://img.shields.io/badge/tests-40-blue.svg)\n![Assertions](https://img.shields.io/badge/assertions-70-blue.svg)\n![Coverage](https://img.shields.io/badge/coverage-70%25-success.svg)\n![Infection](https://img.shields.io/badge/infection-95%25-success.svg)\n\n## steevanb/version-comparator\n\nAdd classes to compare versions easier than with `compare_version()` and `PHP_VERSION`.\n\n[Changelog](changelog.md)\n\n## Installation\n\n```\ncomposer require steevanb/version-comparator ^0.2\n```\n\n## Compare with current PHP version\n\nYou can compare current PHP version with 2 versions to know if current php version is between this 2 versions:\n\n```php\nPhpVersionComparator::isBetween('8', '9'); // return true is PHP is \u003e= 8.0.0 and \u003c 9.0.0\nPhpVersionComparator::isBetween('8.0', '8.1'); // return true is PHP is \u003e= 8.0.0 and \u003c 8.1.0\nPhpVersionComparator::isBetween('8.0.0', '8.0.2'); // return true is PHP is \u003e= 8.0.0 and \u003c 8.0.2\n```\n\n## Shortcuts for each PHP major and minor version\n\n`PhpVersionComparator` have a shortcut who call `isBetween()` for each major and minor version:\n\n```php\n// For PHP 5.3 to 5.6 \nPhpVersionComparator::isPhp5(); // return true is PHP is \u003e= 5.0.0 and \u003c 6.0.0\nPhpVersionComparator::isPhp53(); // return true is PHP is \u003e= 5.3.0 and \u003c 5.4.0\nPhpVersionComparator::isPhp54(); // return true is PHP is \u003e= 5.4.0 and \u003c 5.5.0\nPhpVersionComparator::isPhp55(); // return true is PHP is \u003e= 5.5.0 and \u003c 5.6.0\nPhpVersionComparator::isPhp56(); // return true is PHP is \u003e= 5.6.0 and \u003c 5.7.0\n\n// For PHP 7.0 to 7.4\nPhpVersionComparator::isPhp7(); // return true is PHP is \u003e= 7.0.0 and \u003c 8.0.0\nPhpVersionComparator::isPhp70(); // return true is PHP is \u003e= 7.0.0 and \u003c 7.1.0\nPhpVersionComparator::isPhp71(); // return true is PHP is \u003e= 7.1.0 and \u003c 7.2.0\nPhpVersionComparator::isPhp72(); // return true is PHP is \u003e= 7.2.0 and \u003c 7.3.0\nPhpVersionComparator::isPhp73(); // return true is PHP is \u003e= 7.3.0 and \u003c 7.4.0\nPhpVersionComparator::isPhp74(); // return true is PHP is \u003e= 7.4.0 and \u003c 7.5.0\n\n// For PHP 8.0 to latest 8.x\nPhpVersionComparator::isPhp8(); // return true is PHP is \u003e= 8.0.0 and \u003c 9.0.0\nPhpVersionComparator::isPhp80(); // return true is PHP is \u003e= 8.0.0 and \u003c 8.1.0\nPhpVersionComparator::isPhp81(); // return true is PHP is \u003e= 8.1.0 and \u003c 8.2.0\n```\n\n## Exception instead of returning the result\n\nIf you want to throw an exception instead of returning the result,\neach method have it's `assert()` version who throw a `VersionIsNotBetweenException` exception:\n\n```php\nPhpVersionComparator::assertIsBetween('8', '9');\nPhpVersionComparator::assertIsPhp5();\n// etc\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteevanb%2Fphp-version-comparator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsteevanb%2Fphp-version-comparator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteevanb%2Fphp-version-comparator/lists"}