Search by

akaunting / laravel-version

denisdulicicuneytsenturk

Version management package for Laravel

Package info

github.com/akaunting/laravel-version

pkg:composer/akaunting/laravel-version

Statistics

Installs: 330 201

Dependents: 0

Suggesters: 0

Stars: 38

Open Issues: 0

1.1.0 2026-12-04 21:43 UTC

This package is auto-updated.

Last update: 2026-12-04 21:47:17 UTC


README

Tests Downloads StyleCI License

This is a SemVer compatible version management package for any software built on Laravel.

Requirements

  • PHP 5.5.9 or higher
  • Laravel 5.2 or higher (tested on Laravel 12 and 13)

Getting Started

1. Install

Run the following command:

composer require akaunting/laravel-version

2. Register (for Laravel < 5.5)

On Laravel 5.5 and higher the service provider and the Version facade are registered automatically through package discovery.

On older versions, register the service provider in config/app.php:

Akaunting\Version\Provider::class,

Add the alias if you want to use the facade:

'Version' => Akaunting\Version\Facade::class,

3. Publish

Publish the config file:

php artisan vendor:publish --tag=version

4. Configure

Change the version information of your app in the config/version.php file:

return [
    'name'   => 'My App',
    'code'   => 'Start',
    'major'  => '1',
    'minor'  => '0',
    'patch'  => '0',
    'build'  => '',
    'status' => 'Stable',
    'date'   => '10-August-2017',
    'time'   => '15:30',
    'zone'   => 'GMT +3',
];

Usage

Helper

version('short');     // 1.0.0
version()->short();   // 1.0.0
version('release');   // 1.0
version('full');      // 1.0.0+567 (1.0.0 when build is empty)
version('long');      // My App 1.0.0 Stable [ Start ] 10-August-2017 15:30 GMT +3

Calling version() without an argument returns the Akaunting\Version\Version instance. Only the methods listed below are accepted as a string argument; anything else throws an InvalidArgumentException.

Note: The helper is only defined when no other version() function exists. If another package or your own code defines a global version() function first, that one is used instead of this helper, without any error. In that case use the facade or dependency injection, which always work.

Facade

use Akaunting\Version\Facade as Version;

Version::short();

Dependency injection

use Akaunting\Version\Version;

public function show(Version $version)
{
    return $version->short();
}

Blade

<footer>{{ version('short') }}</footer>

Security: long() reveals the exact version, build and release date of your application, which helps attackers look up known vulnerabilities. Show only short() or release() on public pages, and keep long() and full() for admin panels, logs and the console.

Artisan command

php artisan version                  # My App 1.0.0 Stable [ Start ] 10-August-2017 15:30 GMT +3
php artisan version --format=short   # 1.0.0
php artisan version --format=full    # 1.0.0+567

--format accepts any of the available methods and defaults to long. An unknown format exits with code 1, so the command can be used safely in CI/CD scripts:

APP_VERSION=$(php artisan version --format=short)

Artisan about

On Laravel 9.21 and higher the version information is added to the php artisan about command:

php artisan about --only=version
  Version ............................................................
  Code ........................................................ Start
  Name ....................................................... My App
  Released .............................. 10-August-2017 15:30 GMT +3
  Status ..................................................... Stable
  Version ..................................................... 1.0.0

Available methods

Method Example output
name() My App
code() Start
major() 1
minor() 0
patch() 0
build() ''
status() Stable
date() 10-August-2017
time() 15:30
zone() GMT +3
release() 1.0
short() 1.0.0
full() 1.0.0+567 (1.0.0 when build is empty)
long() My App 1.0.0 Stable [ Start ] 10-August-2017 15:30 GMT +3

Note: full() appends the build metadata with a + sign, as defined by SemVer. Build metadata must be ignored when comparing versions, but PHP's version_compare() does not ignore it (version_compare('1.0.0+567', '1.0.0') returns 1). Use short() to compare versions:

if (version_compare(version('short'), '2.0.0', '>=')) {
    // ...
}

A + is decoded as a space in URL query strings, so encode the value with urlencode() before putting it in a URL.

Testing

composer test

Changelog

Please see Releases for more information what has changed recently.

Contributing

Pull requests are more than welcome. You must follow the PSR coding standards.

Security

If you discover any security related issues, please email security@akaunting.com instead of using the issue tracker.

Credits

License

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