PHP code example of dhii / versions

1. Go to this page and download the library: Download dhii/versions 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/ */

    

dhii / versions example snippets




use Dhii\Versions\StringVersionFactory;

$factory = new StringVersionFactory();
$version = $factory->createVersionFromString('0.1.15-alpha1.2.3+hello.world.987');

echo $version->getMajor(); // 0
echo $version->getMinor(); // 1
echo $version->getPatch(); // 15
var_export($version->getPreRelease()); // ['alpha1', 2, 3]
var_export($version->getBuild()); // ['hello', 'world', '987']