PHP code example of andrelohmann / semver

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

    

andrelohmann / semver example snippets


namespace League\SemVer;

interface Parser
{

    /**
     * @param string $version
     * @return Version
     */
    function parse($version);

    /**
     * @param string $version
     * @return bool
     */
    function isValidVersion($version);

}

$parser = new League\SemVer\RegexParser();
var_dump($parser->parse('not a valid version'));
var_dump($parser->parse('1.0.0-alpha.1+48e4f51e0b2751ec3bc4a2bde809e46d60eb1d6e'));

NULL
object(League\SemVer\Version)#3 (5) {
  ["major"]=>
  string(1) "1"
  ["minor"]=>
  string(1) "0"
  ["patch"]=>
  string(1) "0"
  ["pre_release"]=>
  array(2) {
    [0]=>
    string(5) "alpha"
    [1]=>
    int(1)
  }
  ["build"]=>
  array(1) {
    [0]=>
    string(40) "48e4f51e0b2751ec3bc4a2bde809e46d60eb1d6e"
  }
}