api config get composer.json version number
This commit is contained in:
parent
eb08131df0
commit
022507a72c
2 changed files with 24 additions and 1 deletions
|
|
@ -10,6 +10,14 @@ use Illuminate\Support\Facades\Route;
|
|||
*/
|
||||
class Helper
|
||||
{
|
||||
|
||||
/**
|
||||
* Package infos
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $packageInfos;
|
||||
|
||||
/**
|
||||
* Tells if the request is within apiV2 routes
|
||||
*
|
||||
|
|
@ -71,4 +79,17 @@ class Helper
|
|||
{
|
||||
return Route::getRoutes()->getByName(static::getRouteName($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get composer.json infos
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getPackageInfo(): array
|
||||
{
|
||||
if (!static::$packageInfos) {
|
||||
static::$packageInfos = \json_decode(\file_get_contents(__DIR__ . '/../../composer.json'), true);
|
||||
}
|
||||
return static::$packageInfos;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
<?php
|
||||
|
||||
use App\Lib\Helper;
|
||||
|
||||
return [
|
||||
/**
|
||||
* Api versions
|
||||
** this value is sent in response
|
||||
*/
|
||||
'version' => '2.0.0',
|
||||
'version' => Helper::getPackageInfo()['version'],
|
||||
|
||||
/**
|
||||
* Api Token timeout in minutes
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue