PHP code example of drupify / version-resolver

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

    

drupify / version-resolver example snippets


use Drupify\Resolver\VersionResolver;

// Initialize the resolver with the project name.
$resolver = new VersionResolver('token');

// Get supported releases for the project.
$supported = $resolver->getSupportedReleases();

// Output format example:
[
  "8.x-1.x" => [
    "stable" => [
      "name" => "token 8.x-1.15",
      "version" => "8.x-1.15",
      "tag" => "8.x-1.15",
      "core_compatibility" => "^9.2 || ^10 || ^11"
    ],
    "dev" => [
      "name" => "token 8.x-1.x-dev",
      "version" => "8.x-1.x-dev",
      "tag" => "8.x-1.x",
      "core_compatibility" => "^9.2 || ^10 || ^11"
    ]
  ]
]

$all = $resolver->getAllReleases();

use Drupify\Resolver\CoreVersionResolver;

$resolver = new CoreVersionResolver();

$currentVersion = $resolver->findCurrent();
$currentDevVersion = $resolver->findCurrentDev();
$nextMinorVersion = $resolver->findNextMinor();
$nextMinorDevVersion = $resolver->findNextMinorDev();

echo $currentVersion; // 10.3
echo $currentDevVersion; // 10.3.x-dev
echo $nextMinorVersion; // 11.0.0-rc1
echo $nextMinorDevVersion; // 11.0.x-dev