Skip to content

Instantly share code, notes, and snippets.

@wanmigs
Created June 17, 2019 08:07
Show Gist options
  • Save wanmigs/90db26e95be708f9d7b9ac6fd3052c62 to your computer and use it in GitHub Desktop.
Save wanmigs/90db26e95be708f9d7b9ac6fd3052c62 to your computer and use it in GitHub Desktop.
Laravel System Check Controller Sample
<?php
namespace App\Http\Controllers;
use wanmigs\HealthCheck\SystemCheck;
use Illuminate\Support\Facades\DB;
class SystemController extends Controller
{
private $system;
public function __construct()
{
$this->system = new SystemCheck();
}
public function serverStatus()
{
return $this->system->getStatus();
}
public function releaseInfo()
{
$table = DB::table('migrations');
$latest = $table->max('batch');
$migrations = $table->whereBatch($latest)->get()->pluck('migration');
return array_merge(
$this->system->getPhpInfo(),
[
'database' => [
'schema-version' => '<might-need-to-implement-one>',
'last-migrations' => $migrations
]
],
$this->system->getReleaseInfo()
);
}
}
@wanmigs
Copy link
Author

wanmigs commented Jun 17, 2019

Composer package

composer require wanmigs/system-check

Add the following on routes/web.php

Route::get('/system/application', 'SystemController@serverStatus');
Route::get('/system/release', 'SystemController@releaseInfo');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment