A simple Laravel package to manage versions in your project using either VERSION files or Git tags. No complex configuration required.
- 🚀 Zero Configuration - Works out of the box
- 📄 VERSION File Support - Read version from VERSION files
- 🎯 Git Integration - Uses your existing Git tags as fallback
- 🤐 Silent Git Errors - No error logs when Git is not available
- 🔧 Blade Directive - Easy template integration
- 📱 Laravel 9-12 - Supports Laravel 9, 10, 11, and 12
- PHP 8.1 or higher
- Laravel 9.0 - 12.x
Install the package via Composer:
composer require gdn-dev/laragit-versionThe package will automatically register itself via Laravel's auto-discovery.
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"Use the convenient Blade directive:
{{-- Default format --}}
@laragitVersion
{{-- Compact format --}}
@laragitVersion('compact')// Via service container
$version = app('gdn-dev.laragit-version')->show();
// Via dependency injection
public function __construct(LaragitVersion $laragitVersion)
{
$this->version = $laragitVersion->show();
}The package uses a simple approach:
'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')- First checks for a VERSION file in your project root
- If found, uses the content as the version
- If not found, checks if Git is available
- If Git is available, tries to get the version from Git tags
- If Git is not available or no tags found, returns "0.0.0" as default
- Never produces error logs when Git is not available
The MIT License (MIT). Please see License File for more information.
Give a ⭐️ if this project helped you!
Made with ❤️ by Genial Digital Nusantara