48 lines
2.5 KiB
PHP
48 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Superuser;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Contracts\View\View;
|
|
|
|
/** Ringkasan kondisi sistem dari konfigurasi dan pemeriksaan sederhana pada server ini. */
|
|
class KesehatanSistemController extends Controller
|
|
{
|
|
public function __invoke(): View
|
|
{
|
|
$total = @disk_total_space(storage_path());
|
|
$bebas = @disk_free_space(storage_path());
|
|
$terpakai = ($total && $bebas !== false) ? $total - $bebas : null;
|
|
$gb = fn (float|int $bytes): float => round($bytes / 1024 ** 3, 1);
|
|
|
|
$layanan = [
|
|
['nama' => 'Basis data', 'nilai' => (string) config('database.default'), 'icon' => 'circle-stack'],
|
|
['nama' => 'Cache', 'nilai' => (string) config('cache.default'), 'icon' => 'cube'],
|
|
['nama' => 'Antrean tugas', 'nilai' => (string) config('queue.default'), 'icon' => 'queue-list'],
|
|
['nama' => 'Penyimpanan sesi', 'nilai' => (string) config('session.driver'), 'icon' => 'finger-print'],
|
|
['nama' => 'Surel keluar', 'nilai' => (string) config('mail.default'), 'icon' => 'document-text'],
|
|
];
|
|
|
|
$periksa = [
|
|
['nama' => 'Mode debug nonaktif', 'ok' => ! config('app.debug'), 'catatan' => config('app.debug') ? 'APP_DEBUG menyala; matikan di produksi.' : 'APP_DEBUG mati.'],
|
|
['nama' => 'Kunci aplikasi terisi', 'ok' => filled(config('app.key')), 'catatan' => filled(config('app.key')) ? 'APP_KEY tersedia.' : 'Jalankan php artisan key:generate.'],
|
|
['nama' => 'Folder storage dapat ditulis', 'ok' => is_writable(storage_path()), 'catatan' => storage_path()],
|
|
['nama' => 'Folder bootstrap/cache dapat ditulis', 'ok' => is_writable(base_path('bootstrap/cache')), 'catatan' => base_path('bootstrap/cache')],
|
|
['nama' => 'Lingkungan produksi', 'ok' => app()->isProduction(), 'catatan' => 'Lingkungan saat ini: '.app()->environment().'.'],
|
|
];
|
|
|
|
return view('superuser.kesehatan-sistem.index', [
|
|
'versi' => [
|
|
'Laravel' => app()->version(),
|
|
'PHP' => PHP_VERSION,
|
|
'Lingkungan' => app()->environment(),
|
|
'Zona waktu' => (string) config('app.timezone'),
|
|
],
|
|
'layanan' => $layanan,
|
|
'periksa' => $periksa,
|
|
'disk' => $terpakai === null ? null : ['terpakai' => $gb($terpakai), 'total' => $gb($total)],
|
|
'lolos' => collect($periksa)->where('ok', true)->count(),
|
|
]);
|
|
}
|
|
}
|