承接 eznix86/laravel-version 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

eznix86/laravel-version

最新稳定版本:v2.1.2

Composer 安装命令:

composer require eznix86/laravel-version

包简介

Semantic app versioning for Laravel with git integration.

README 文档

README

Semantic versioning for Laravel applications with git integration.

Installation

composer require eznix86/laravel-version

Publish the configuration and version file:

php artisan vendor:publish --tag=version-config
php artisan vendor:publish --tag=version-json

Usage

Commands

# Show current version
php artisan version:show

# Bump version
php artisan version:bump patch      # 1.0.0 → 1.0.1
php artisan version:bump minor      # 1.0.0 → 1.1.0
php artisan version:bump major      # 1.0.0 → 2.0.0

# Pre-release versions
php artisan version:bump alpha      # 1.0.0 → 1.0.0-alpha.1
php artisan version:bump beta       # 1.0.0 → 1.0.0-beta.1
php artisan version:bump rc         # 1.0.0 → 1.0.0-rc.1

# With build metadata
php artisan version:bump patch --build=123              # 1.0.0 → 1.0.1+123
php artisan version:bump minor --build=$(git rev-parse --short HEAD)

# Skip git commit/tag
php artisan version:bump patch --no-git

# Set version to specific value
php artisan version:set 2.0.0         # Set version to 2.0.0
php artisan version:set 1.2.3-alpha.1  # Set version with pre-release
php artisan version:set 1.0.0+build.1  # Set version with build metadata
php artisan version:set 2.1.0 --no-git  # Skip git integration

# Set version from latest git tag
php artisan version:set --match-git-tags            # Use latest git tag as version (commits, doesn't create tag)
php artisan version:set --match-git-tags --no-git   # Use latest git tag but skip commit/tag

Helper

// Mirrors the Version Facade

version()->get();              // "1.0.0"
version()->major();            // 1
version()->minor();            // 0
version()->patch();            // 0
version()->preRelease();       // null or "alpha.1"
version()->build();            // null or "123"
version()->isStable();         // true
version()->isPreRelease();     // false

// Comparisons
version()->gt('0.9.0');                  // true
version()->isGreaterThan('0.9.0');       // true (alias of gt)
version()->gte('1.0.0');                 // true
version()->isGreaterThanOrEqualTo('1.0.0'); // true (alias of gte)
version()->lt('2.0.0');                  // true
version()->isLessThan('2.0.0');          // true (alias of lt)
version()->lte('1.0.0');                 // true
version()->isLessThanOrEqualTo('1.0.0'); // true (alias of lte)
version()->eq('1.0.0');                  // true
version()->isCompatibleWith('1.0.0');    // true (alias of eq)
version()->neq('2.0.0');                 // true
version()->isNotEqualTo('2.0.0');        // true (alias of neq)

Blade

<footer>@version</footer>  <!-- outputs: v1.0.0 (with default prefix) -->

The @version directive automatically includes the configured prefix.

Facade

use Eznix86\Version\Facades\Version;

Version::get();
Version::incrementMinor();

Configuration

// config/version.php
return [

    /*
    |--------------------------------------------------------------------------
    | Version Prefix
    |--------------------------------------------------------------------------
    |
    | This value is prepended to the version string when using the @version
    | Blade directive. Set to an empty string to disable the prefix.
    |
    */

    'prefix' => 'v',

    /*
    |--------------------------------------------------------------------------
    | Git Integration
    |--------------------------------------------------------------------------
    |
    | When enabled, version bumps will automatically create a git commit and
    | tag. You can customize the commit message and tag format using the
    | {version} placeholder which will be replaced with the new version.
    |
    */

    'git' => [
        'enabled' => true,
        'commit_message' => 'Bump version to {version}',
        'tag_format' => 'v{version}',
    ],

];

Artisan About

The package automatically registers the version in Laravel's about command:

php artisan about

This will display your application version in the Application section.

Production Protection

To prevent accidental version changes in production, add this to your AppServiceProvider:

use Eznix86\Version\Version;

public function boot(): void
{
    Version::prohibitCommands($this->app->isProduction());
}

Or prohibit commands individually:

use Eznix86\Version\Commands\VersionBumpCommand;
use Eznix86\Version\Commands\VersionSetCommand;

public function boot(): void
{
    VersionBumpCommand::prohibit($this->app->isProduction());
    VersionSetCommand::prohibit($this->app->isProduction());
}

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-11