定制 gdn-dev/laragit-version 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gdn-dev/laragit-version

最新稳定版本:1.0.3

Composer 安装命令:

composer require gdn-dev/laragit-version

包简介

Simple Laravel package to manage versions using VERSION files or Git tags

README 文档

README

Latest Version on Packagist Tests Total Downloads

A simple Laravel package to manage versions in your project using either VERSION files or Git tags. No complex configuration required.

✨ Features

  • 🚀 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

📋 Requirements

  • PHP 8.1 or higher
  • Laravel 9.0 - 12.x

📦 Installation

Install the package via Composer:

composer require gdn-dev/laragit-version

The package will automatically register itself via Laravel's auto-discovery.

🚀 Quick Start

Basic Usage

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();

Using VERSION File

// 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"

Blade Templates

Use the convenient Blade directive:

{{-- Default format --}}
@laragitVersion

{{-- Compact format --}}
@laragitVersion('compact')

Service Container

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

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

🎯 How It Works

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')
  1. First checks for a VERSION file in your project root
  2. If found, uses the content as the version
  3. If not found, checks if Git is available
  4. If Git is available, tries to get the version from Git tags
  5. If Git is not available or no tags found, returns "0.0.0" as default
  6. Never produces error logs when Git is not available

📄 License

The MIT License (MIT). Please see License File for more information.

👥 Credits

⭐ Show Your Support

Give a ⭐️ if this project helped you!

Made with ❤️ by Genial Digital Nusantara

统计信息

  • 总下载量: 59
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-24