granam/web-versions

Reads available minor and patch versions from a Git repository

1.1.1 2021-08-30 07:07 UTC

This package is auto-updated.

Last update: 2024-03-29 04:19:37 UTC


README

Reads minor versions, like 1.0, 1.1, 2.0 and patch versions, like 1.0.0, 1.0.1, 1.1.0, 2.0.0, 2.0.1 from given Git repository.

Originally created for a cache invalidation using a Git version as a cache key (that is where the Web versions name came from).

Caveats

  • Minor versions reads only from Git branches, filtered for those named version-like (v1.0 or 1.0)
  • Patch versions reads only from Git tags, filtered for those named version-like (v1.0.0 or 1.0.0)

Usage

<?php
require_once __DIR__ . '/vendor/autoload.php';

$git = new \Granam\Git\Git();
$webVersions = new \Granam\WebVersions\WebVersions($git, __DIR__, 'dev-branch-name');

print_r($webVersions->getAllMinorVersions()); // Array ( [0] => dev-branch-name [1] => 1.0 )

print_r($webVersions->getAllStableMinorVersions()); // Array ( [0] => 1.0 )

print_r($webVersions->getAllPatchVersions()); // Array ( [0] => dev-branch-name [1] => 1.0.0 )

print_r($webVersions->getAllStablePatchVersions()); // Array ( [0] => 1.0.0 ) 

Install

Easiest via Composer

composer require granam/web-versions