PHP code example of gdn-dev / laragit-version

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

    

gdn-dev / laragit-version example snippets


use GenialDigitalNusantara\LaragitVersion\Facade as LaragitVersion;

// Get version with default formatting
echo LaragitVersion::show(); // "Version 1.0.0"

// Get compact version
echo LaragitVersion::show('compact'); // "v1.0.0"

// Get version info as array
$info = LaragitVersion::getVersionInfo();

// Create VERSION file in project root
file_put_contents(base_path('VERSION'), '2.1.0');

// Use normally
echo LaragitVersion::show(); // "Version 2.1.0"
echo LaragitVersion::show('compact'); // "v2.1.0"

// Via service container
$version = app('gdn-dev.laragit-version')->show();

// Via dependency injection
public function __construct(LaragitVersion $laragitVersion)
{
    $this->version = $laragitVersion->show();
}

'version' => file_exists(base_path('VERSION')) 
    ? trim(file_get_contents(base_path('VERSION')))
    : (isGitAvailable() 
        ? trim(exec('git describe --tags --abbrev=0 2>/dev/null'))
        : '0.0.0')