PHPackages                             othercode/laravel-version - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. othercode/laravel-version

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

othercode/laravel-version
=========================

A tiny port-adapter version resolver for Laravel apps. Pluggable sources: VERSION file, env var, git tag, or config array.

v0.2.0(3mo ago)0333MITPHPPHP ^8.3CI passing

Since Apr 24Pushed 3mo agoCompare

[ Source](https://github.com/othercode/laravel-version)[ Packagist](https://packagist.org/packages/othercode/laravel-version)[ RSS](/packages/othercode-laravel-version/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (8)Versions (3)Used By (0)

Laravel Version
===============

[](#laravel-version)

A tiny port-adapter version resolver for Laravel apps. Pluggable sources: `VERSION` file, env var, git tag, or config array.

```
composer require othercode/laravel-version

```

- PHP **^8.3**
- Laravel **^11.0 || ^12.0**

Usage
-----

[](#usage)

The package auto-registers its service provider and ships a `version()` helper. Anywhere in your app:

```
$version = version();              // SemanticVersion instance
(string) $version;                 // "1.2.3-beta"
$version->major;                   // "1"
$version->minor;                   // "2"
$version->patch;                   // "3"
$version->status;                  // "beta"
```

Prefer explicit DI? Resolve the manager yourself:

```
use OtherCode\Laravel\Version\VersionManager;

$version = app(VersionManager::class)->version();
```

Choosing a source
-----------------

[](#choosing-a-source)

Configure via `config/version.php` (publish with `php artisan vendor:publish --tag=version-config`) or env vars:

```
VERSION_SOURCE=file                 # file | env | git | config
VERSION_FILE_PATH=VERSION           # used when VERSION_SOURCE=file
VERSION_ENV_KEY=version.value       # used when VERSION_SOURCE=env
APP_VERSION=v1.2.3-beta             # used when VERSION_SOURCE=env
VERSION_CONFIG_PREFIX=version       # used when VERSION_SOURCE=config
```

### `file` (default)

[](#file-default)

Reads a plain-text `VERSION` file at the app base path. Great for build-time injection:

```
# build.sh
git describe --tags --abbrev=0 > VERSION
```

### `env`

[](#env)

Reads `config('version.value')`, typically fed by `APP_VERSION`. Ideal for platforms like Laravel Cloud where the deploy system injects the release tag as an environment variable. Laravel Cloud does **not** auto-inject a version — set `APP_VERSION` per release in the dashboard.

### `git`

[](#git)

Runs `git describe --tags --abbrev=0` via Symfony Process. Useful in **dev** and **CI build steps**, not in container runtimes: Docker images built from your repo typically do not ship the `.git` directory, so this adapter will fall back to `v0.0.0-dev` in production.

### `config`

[](#config)

Reads four keys from a config bag: `{prefix}.major`, `{prefix}.minor`, `{prefix}.patch`, `{prefix}.status` (prefix defaults to `version`). Ideal when your app already keeps hardcoded version fragments in `config/version.php` and you want the file to stay pure data:

```
// config/version.php (consumer app)
return [
    'source' => 'config',

    'major' => '1',
    'minor' => '2',
    'patch' => '3',
    'status' => 'beta',
];
```

Using a custom source
---------------------

[](#using-a-custom-source)

Bind your own adapter anywhere (e.g. in a service provider):

```
use OtherCode\Laravel\Version\Contracts\VersionSource;
use OtherCode\Laravel\Version\SemanticVersion;

$this->app->singleton(VersionSource::class, fn () => new class implements VersionSource {
    public function version(): SemanticVersion {
        return SemanticVersion::fromString('1.0.0');
    }
});
```

Semantic version value object
-----------------------------

[](#semantic-version-value-object)

`SemanticVersion` is a tiny immutable VO that parses `[v]MAJOR[.MINOR[.PATCH]][-STATUS]`:

```
use OtherCode\Laravel\Version\SemanticVersion;

SemanticVersion::fromString('v2.5.0-rc1');
SemanticVersion::fromString('2.5');       // pads MINOR/PATCH with "0"
SemanticVersion::fromString('');          // throws InvalidArgumentException
```

The `version()` helper
----------------------

[](#the-version-helper)

The package registers a global `version()` function guarded by `function_exists()`. If something in your app already defines `version()`, ours is silently skipped and you can still use `app(VersionManager::class)->version()` directly.

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance82

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

92d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7958790dcf5cd51ebbadc52fc7bada326fb3edd4481decf1006e6cfed8e46c43?d=identicon)[usantisteban](/maintainers/usantisteban)

---

Top Contributors

[![othercodes](https://avatars.githubusercontent.com/u/4815856?v=4)](https://github.com/othercodes "othercodes (3 commits)")

---

Tags

laravellaravel-frameworklaravel-packageversioninglaravelsemverversionSemantic versionport-adapter

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/othercode-laravel-version/health.svg)

```
[![Health](https://phpackages.com/badges/othercode-laravel-version/health.svg)](https://phpackages.com/packages/othercode-laravel-version)
```

###  Alternatives

[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k95.4M321](/packages/laravel-horizon)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77922.3M186](/packages/laravel-mcp)[illuminate/queue

The Illuminate Queue package.

20432.6M1.7k](/packages/illuminate-queue)[spatie/laravel-health

Monitor the health of a Laravel application

87912.0M177](/packages/spatie-laravel-health)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
