1. Go to this page and download the library: Download naneau/semver 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/ */
naneau / semver example snippets
use Naneau\SemVer\Parser;
// Parse a SemVer string
$version = Parser::parse('1.2.3-alpha.1+build.12345.ea4f51');
// Root parts
echo $version->getMajor(); // => 1
echo $version->getMinor(); // => 2
echo $version->getPatch(); // => 3
// Pre-release part ('-alpha.1')
if ($version->hasPreRelease()) {
echo $version->getPreRelease()->getGreek(); // => alpha
echo $version->getPreRelease()->getReleaseNumber(); // => 1
echo $version->getPreRelease() // => alpha.1
}
// Build part ('+build.12345')
if ($version->hasBuild()) {
echo $version->getBuild()->getNumber(); // => 12345
var_dump($version->getBuild()->getParts()); // => array(0 => 'ea4f51');
}
// Full version echo
echo $version; // => 1.2.3-alpha.1+build.12345.ea4f51