This package adds a Filament page for monitoring checks registered with spatie/laravel-health. It supports Filament 4 and 5 and PHP 8.2 or newer.
Install the package via Composer:
composer require shuvroroy/filament-spatie-laravel-healthLaravel Health can store results in various ways. If you use its default Eloquent result store, publish and run the migration that creates the health_check_result_history_items table:
php artisan vendor:publish --tag="health-migrations"
php artisan migratePublish Filament's assets:
php artisan filament:assetsRegister the plugin in your Filament panel provider, such as AdminPanelProvider:
<?php
namespace App\Providers\Filament;
use Filament\Panel;
use Filament\PanelProvider;
use ShuvroRoy\FilamentSpatieLaravelHealth\FilamentSpatieLaravelHealthPlugin;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(FilamentSpatieLaravelHealthPlugin::make());
}
}Register your health checks in the boot() method of app/Providers/AppServiceProvider.php:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Spatie\Health\Facades\Health;
use Spatie\Health\Checks\Checks\DebugModeCheck;
use Spatie\Health\Checks\Checks\EnvironmentCheck;
use Spatie\Health\Checks\Checks\OptimizedAppCheck;
class AppServiceProvider extends ServiceProvider
{
public function boot(): void
{
Health::checks([
OptimizedAppCheck::new(),
DebugModeCheck::new(),
EnvironmentCheck::new(),
]);
}
}See the available checks in the Laravel Health documentation.
The plugin exposes methods for changing the page's navigation group, sort order, icon, and label. Each option also accepts a closure when the value needs to be determined at runtime.
FilamentSpatieLaravelHealthPlugin::make()
->navigationGroup('System')
->navigationSort(10)
->navigationIcon('heroicon-o-cpu-chip')
->navigationLabel('Application Health');Pass null to navigationGroup() to remove the default navigation group. Pass null to navigationLabel() to use the translated default label.
Extend the default page when you need to customise page-specific behavior, such as its heading or view. Configure navigation through the plugin methods described above.
<?php
namespace App\Filament\Pages;
use Illuminate\Contracts\Support\Htmlable;
use ShuvroRoy\FilamentSpatieLaravelHealth\Pages\HealthCheckResults as BaseHealthCheckResults;
class HealthCheckResults extends BaseHealthCheckResults
{
public function getHeading(): string | Htmlable
{
return 'Health Check Results';
}
}Then pass the custom page class to the plugin in your panel provider:
<?php
namespace App\Providers\Filament;
use App\Filament\Pages\HealthCheckResults;
use Filament\Panel;
use Filament\PanelProvider;
use ShuvroRoy\FilamentSpatieLaravelHealth\FilamentSpatieLaravelHealthPlugin;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(
FilamentSpatieLaravelHealthPlugin::make()
->usingPage(HealthCheckResults::class),
);
}
}The page is accessible by default. Pass a boolean or closure to authorize() to restrict access:
<?php
namespace App\Providers\Filament;
use Filament\Panel;
use Filament\PanelProvider;
use ShuvroRoy\FilamentSpatieLaravelHealth\FilamentSpatieLaravelHealthPlugin;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(
FilamentSpatieLaravelHealthPlugin::make()
->authorize(fn (): bool => auth()->user()?->email === 'admin@example.com'),
);
}
}Please see UPGRADE for details on how to upgrade 1.X to 2.0.
composer test
composer test:coverage
composer analyse
composer formatThe coverage command requires Xdebug or PCOV and fails when coverage is below 100%.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.