Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to specify an app version on a Laravel app?

I used to specify the app version inside composer.json until I read somewhere here in Stack Overflow that it was a bad practice. What is the standard file to specifying the app version on a PHP Laravel application? (i.e: in .NET that'd be the config file, on iOS it'd be the info.plist, on Android it'd be the Manifest, etc...)

like image 647
Christopher Francisco Avatar asked Aug 18 '15 00:08

Christopher Francisco


People also ask

How do I know what version of Laravel app I have?

Every Laravel release has the version of the framework as constant in the Application. php file. You can access this constant via the app() helper. If you don't want to create a /test route to get the version, you can use php artisan tinker to get into the tinker REPL and run it from there.

How can I change Laravel version?

change laravel/framework value inside composer. json to the new version (e.g. 6.18) run composer update.

What is version control in Laravel?

Version Control for Laravel is a package that provides database version control for Eloquent models. This package works by creating a separate *_versions database table that corresponds with the model (i.e., users_versions ).

Where is config in Laravel?

All of the configuration files for the Laravel framework are stored in the app/config directory. Each option in every file is documented, so feel free to look through the files and get familiar with the options available to you.


2 Answers

config/app.php is definitely the place for such information.

Why ? Because the configuration files are (or should be) included in your versioning flow and they (should) contain non-sensitive information about your application. The perfect place for a simple version indicator.

under the name index of the array, you could set a version index like this

/*
|--------------------------------------------------------------------------
| Application Version
|--------------------------------------------------------------------------
|
| This value is the version of your application. This value is used when
| the framework needs to place the application's version in a notification
| or any other location as required by the application or its packages.
*/

'version' => '1.0.0',
like image 83
George Dimitriadis Avatar answered Dec 09 '22 01:12

George Dimitriadis


@delatbabel

has a great start for version

config/app.php

'version' => env('APP_VERSION', '1.0.0'),

for config/bugsnag:

'app_version' => env('APP_VERSION', '1.0.0'),

then you can simply get your version with:

config('app.version')

Docker

now in docker you could set a default version on build:

ENV APP_VERSION=1.0.0

for example with circle CI you can add your build number:

ARG BUILD_NR
ENV APP_VERSION=1.0.$BUILD_NR

Now in your config.yml, you can add following job commando:

 deliver-prod:
    machine: true
    steps:
      - checkout
      - docker build --build-arg BUILD_NR=$CIRCLE_BUILD_NUM .
like image 30
Joel Harkes Avatar answered Dec 09 '22 00:12

Joel Harkes