PHP code example of tobya / laravel-version

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

    

tobya / laravel-version example snippets



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

use Tobya\Version\Facades\Version;

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

// 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}',
    ],

];

use Tobya\Version\Version;

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

use Tobya\Version\Commands\VersionBumpCommand;
use Tobya\Version\Commands\VersionSetCommand;

public function boot(): void
{
    VersionBumpCommand::prohibit($this->app->isProduction());
    VersionSetCommand::prohibit($this->app->isProduction());
}
bash
php artisan vendor:publish --tag=version-config
php artisan vendor:publish --tag=version-json
bash
php artisan about