1. Go to this page and download the library: Download mistralys/version-parser library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Mistralys\VersionParser\VersionParser;
$version = VersionParser::create('1.5.2-beta');
$isBeta = $version->isBeta(); // true
use Mistralys\VersionParser\VersionParser;
$version = VersionParser::create('1.5.2-beta5');
if($version->getTagType() === VersionParser::TAG_TYPE_BETA)
{
// is a beta version
}
use Mistralys\VersionParser\VersionParser;
$tag = VersionParser::create('1.5.2-B2')->getTagInfo();
if($tag !== null)
{
echo $tag->getTagName(); // b
echo $tag->getTagType(); // beta
}
use Mistralys\VersionParser\VersionParser;
$version = VersionParser::create('1.5.2-BranchName-alpha5');
echo $version
->setSeparatorChar('_')
->getTagVersion();
use Mistralys\VersionParser\VersionParser;
$version = VersionParser::create('1.5.2-BranchName-alpha5');
echo $version
->setTagUppercase()
->getTagVersion();
use Mistralys\VersionParser\VersionParser;
// The third parameter is the short variant of the tag type.
VersionParser::registerTagType('foobar', 5, 'f');
$version = VersionParser::create('1.0.5-foobar2');
$short = VersionParser::create('1.0.5-F2');
echo $version->getTagType(); // foobar
echo $short->getTagType(); // foobar
use Mistralys\VersionParser\VersionParser;
$weight = 900; // Can be any number
VersionParser::registerTagType(VersionParser::TAG_TYPE_ALPHA, $weight--);
VersionParser::registerTagType(VersionParser::TAG_TYPE_BETA, $weight--);
VersionParser::registerTagType('foobar', $weight--);
VersionParser::registerTagType(VersionParser::TAG_TYPE_RELEASE_CANDIDATE, $weight--);
VersionParser::registerTagType('prefinal', $weight--);