krisell / deployed-version-laravel
Adds a route to show currently running version
Installs: 7 472
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires (Dev)
- orchestra/testbench: ^3.8
- phpunit/phpunit: ^8.3
This package is auto-updated.
Last update: 2024-11-09 19:29:13 UTC
README
This package helps with determining which version of your app is currently running. This is useful during a deploy, to see when it is finished, and also when you rollback to ensure that the correct version is loaded.
Installation
Add the package to your Laravel project.
composer require krisell/deployed-version-laravel
The package is configured for automatic discovery, so unless you have other settings, you do not need to manually add the service provider.
Usage
The package by default adds a route /version
which displays the value of the environment-variable VERSION
.
You need to set the value of this variable during your build or deploy process.
VERSION=YOUR_VERSION_VALUE
One way to achieve this is to run the following script, which uses the git hash as the version number, but you may do it however you like:
echo "VERSION=$(git -C gitdir rev-parse HEAD)" >> .env.current-build
.env.current-build
refers to a copy of the .env-file
, to ensure that the addition is not persistent.
The route can be customized by setting an optional prefix,
VERSION_ROUTE_PREFIX=custom-prefix
Which makes the route /custom-prefix/version
.
The route returns simple JSON data,
{ "version": "version-number" }
Licence
MIT
Author
Martin Krisell (martin.krisell@gmail.com)