An open API service indexing awesome lists of open source software.

https://github.com/aliirfaan/laravel-simple-force-update

Very often we want clients, especially mobile applications to update to the latest version. To enable force update feature, we need to keep release versions in our database and compare with the version of the device. This package creates a table to keep releases and provides a service to suggest actions based on version comparison.
https://github.com/aliirfaan/laravel-simple-force-update

force-update laravel semantic-versioning

Last synced: 5 months ago
JSON representation

Very often we want clients, especially mobile applications to update to the latest version. To enable force update feature, we need to keep release versions in our database and compare with the version of the device. This package creates a table to keep releases and provides a service to suggest actions based on version comparison.

Awesome Lists containing this project

README

          

# Laravel Simple Force Update

Very often we want clients, especially mobile applications to update to the latest version. To enable force update feature, we need to keep release versions in our database and compare with the version of the device. This package creates a table to keep releases and provides a service to suggest actions based on version comparison.

## Features

* Table structure to keep versions with support for multiple applications and platforms
* Uses semantic versioning format to keep versions
* Provides interface so that you can implement your own force update logic
* Throws custom exception when invalid semantic string is encountered

## Default force update logic
* candidate version == max version || candidate version > max version : No action
* candidate version < max version && candidate version > min version : Action: update available
* candidate version < min version : Action: update required / force update
* candidate version == min version : Action: update available

## Requirements

* [Composer](https://getcomposer.org/)
* [Laravel](http://laravel.com/)
* [naneau/semver](https://github.com/naneau/semver)

## Installation

You can install this package on an existing Laravel project with using composer:

```bash
$ composer require aliirfaan/laravel-simple-force-update
```

Register the ServiceProvider by editing **config/app.php** file and adding to providers array:

```php
aliirfaan\LaravelSimpleForceUpdate\SimpleForceUpdateProvider::class,
```

Note: use the following for Laravel <5.1 versions:

```php
'aliirfaan\LaravelSimpleForceUpdate\SimpleForceUpdateProvider',
```

Publish files with:

```bash
$ php artisan vendor:publish --provider="aliirfaan\LaravelSimpleForceUpdate\SimpleForceUpdateProvider"
```

or by using only `php artisan vendor:publish` and select the `aliirfaan\LaravelSimpleForceUpdate\SimpleForceUpdateProvider` from the outputted list.

Apply the migrations:

```bash
$ php artisan migrate
```

## Usage

```php
getVersions($appName, $platform);
dd($result);

// get version by application and platform.
$appName = 'default';
$platform = 'android';

$result = $simpleForceUpdateService->getVersions($appName, $platform);
dd($result);

// get update action based on a candidate version.
$candidateVersion = '2.0.9'; // this is normally the version currently installed on the client/device
$appName = 'default';
$platform = 'android';

$result = $simpleForceUpdateService->getApplicationCompatibility($candidateVersion, $appName, $platform);
dd($result);

}
}
```

## Implement your own force update logic

To implement your own force update logic, create a class that extends the **aliirfaan\LaravelSimpleForceUpdate\Contracts\AbstractSimpleForceUpdate** class

```php