PHP code example of renslabs / version

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

    

renslabs / version example snippets


Version::compact()

Version::awesome()

Version::version() // 1.2.25

Version::commit() // 703110

Version::major() // 1

Version::minor() // 2

Version::patch() // 25

Version::format('full') // version 1.0.0 (commit 703110)

Version::full() // version 1.0.0 (commit 703110) -- dynamic method

Version::format('compact') // v.1.0.0-703110

Version::compact() // v.1.0.0-703110 -- dynamic method

// Get recent tags
$tags = Version::getRecentTags(5);

// Get specific tag information
$tagInfo = Version::getTagInfo('v1.2.3');

// Get changelog between tags
$changelog = Version::getChangelogBetween('v1.2.0', 'v1.2.3');

// Get all tags with messages
$allTags = Version::getAllTags();

// Generic changelog method with options
$changelog = Version::getChangelog([
    'from' => 'v1.2.0',
    'to' => 'v1.2.3',
    'limit' => 10
]);

// Get all tags with their complete changelogs
$allTagsWithChangelogs = Version::getAllTagsWithChangelogs(5);

dd(
    Version::format()
);

$version = new \Renslabs\Version\Package\Version();

dd(
    $version->format()
);

dd(
    app(\Renslabs\Version\Package\Version::class)->format()
);

@version

@version('full')
@version('compact')

@printversion('compact')

@version
bash
php artisan version:commit
bash
$ php artisan version:major
$ php artisan version:minor
$ php artisan version:patch
$ php artisan version:build



namespace App\Exceptions;

use Renslabs\Version\Package\Version;
use Bugsnag\BugsnagLaravel\Facades\Bugsnag;

class Handler extends ExceptionHandler
{
    public function report(Exception $exception)
    {
        if ($this->shouldReport($exception)) {
            Bugsnag::setAppVersion((new Version())->format('version'));
            Bugsnag::notifyException($exception);
        }
    }
}

php artisan version:timestamp
text
$ php artisan version:minor
New timestamp: 2019-09-16 18:23:03
MyApp version 2.3.2 (commit 49ffe2)
bash
$ php artisan version:changelog --tag=v1.2.3
Tag: v1.2.3
Date: 2023-12-15 10:30:00
Author: John Doe <[email protected]>
Message:
Fixed critical security issue

- Updated dependencies
- Patched vulnerability in authentication
- Improved error handling

Commits in this tag:
  a1b2c3d4 Fixed authentication vulnerability
  e5f6g7h8 Updated dependencies
  i9j0k1l2 Improved error handling
bash
$ php artisan version:absorb
text
$ php artisan version:minor
New minor version: 5
MyApp version 1.5.0 (commit 701045)
bash
$ php artisan vendor:publish --provider="Renslabs\Version\Package\ServiceProvider"
json
"post-autoload-dump": [
    ...
    "@php artisan version:refresh"
]
bash
#!/bin/sh

php artisan version:refresh