j2nlab / laravel-simple-version
Manage easily your Laravel app version
Requires
- php: >=7.2
- illuminate/console: ^6.0|^7.0|^8.0
- illuminate/view: ^6.0|^7.0|^8.0
Requires (Dev)
- laravel/framework: ^6.0|^7.0
- orchestra/testbench: ^4.0|^5.0
- phpunit/phpunit: ^8.0|^9.0
This package is auto-updated.
Last update: 2024-09-29 05:29:09 UTC
README
Manage easily your Laravel app version
Description
With this package, you can:
- print a version on a page;
- print it in the console, via an artisan command;
- increments version number, via an artisan command.
Installation
Via Composer
$ composer require j2nlab/laravel-simple-version
Then publish the configuration file:
$ php artisan vendor:publish --provider="J2Nlab\SimpleVersion\ServiceProvider"
The initial config/version.php
is:
<?php return array ( 'major' => 0, 'minor' => 0, 'patch' => 0, 'build' => false, 'commit' => false, );
If build is false
, then this number is ignored; else it's incremented and never reset to 0.
If you want a build number, set to any value (0 or 1, for example).
If commit is false
, this number is ignored; else get the 6 firsts digits of the last local commit.
If you want a commit number, set to (0 or 1, for example).
Artisan commands
All available commands are:
$ php artisan version $ php artisan version:major $ php artisan version:minor $ php artisan version:patch $ php artisan version:build $ php artisan version:commit
php artisan version
Display version number, in different ways available with helpers and Blade directive, currently 'full' and 'compact' (the default).
$ php artisan version Version (compact): 1.1.1-11-f44744 Version (full): version 1.1.1 (build: 11) (commit: f44744)
If build value is false
.
$ php artisan version Version (compact): 1.1.1-f44744 Version (full): version 1.1.1 (commit: f44744)
If build and commit values are false
.
$ php artisan version Version (compact): 1.1.1 Version (full): version 1.1.1
If patch and build value are false
.
$ php artisan version Version (compact): 1.1-f44744 Version (full): version 1.1 (commit: f44744)
php artisan version:commit
If the commit value on config/version.php
is not false
, get the 6 firsts digits of the last git local commit.
$ php artisan version:commit New commit number: db5a4a New version: 1.1.1-9-db5a4a
Of, if commit value is false
.
$ php artisan version:commit
No commit number!
php artisan version:build
If the build value on config/version.php
is not false
, increment build number.
This number is never reseted to 0.
$ php artisan version:build New build number: 12 New version: 1.1.1-12-db5a4a
Of, if build value is false
.
$ php artisan version:build
No build number!
php artisan version:patch
If the patch value on config/version.php
is not false
, increment app patch number.
$ php artisan version:patch New major version: 2 New version: 1.1.2-12-db5a4a
Of, if patch value is false
.
$ php artisan version:patch
No patch number!
php artisan version:minor
Increment app minor number version, and reset to 0 patch number.
$ php artisan version:minor New minor version: 2 New version: 1.2.0-12-db5a4a
php artisan version:major
Increment app major number version, and reset to 0 minor and patch numbers.
$ php artisan version:major New major version: 2 New version: 2.0.0-12-db5a4a
Summary...
It's really simple:
'major' => 0,
is incremented byversion:major
'minor' => 0,
is incremented byversion:minor
, reset to 0 byversion:major
'patch' => 0,
is incremented byversion:patch
, reset to 0 byversion:major
/minor
'build' => 0,
is incremented byversion:build
'build' => false,
is never incremented'commit' => 0,
is set with 6 firsts digits of last git commit byversion:commit
'commit' => false,
is never get
Helper
You can use this helper to get a compact version format:
$version = version();
Or you can choose the format:
$version = version('compact'); $version = version('full');
Blade directive
You can use this directive to render a compact version format:
@version
Or you can choose the format:
@version('compact') @version('full')
Testing
You can run some PHPunit tests with the following command:
$ composer test
License
This package is licensed under the MIT License - see the LICENSE file for details.