PHP code example of waypointer-digital / health-laravel
1. Go to this page and download the library: Download waypointer-digital/health-laravel library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
waypointer-digital / health-laravel example snippets
return [
'enabled' => env('KANBINO_HEALTH_ENABLED', true),
'path' => env('KANBINO_HEALTH_PATH', '/health'),
'middleware' => ['web'],
'token' => env('KANBINO_HEALTH_TOKEN'),
'stack' => [
'enabled' => true,
'packages' => ['nginx', 'postgresql', 'redis-server', 'php8.5-fpm', /* ... */],
'cache_seconds' => 3600,
],
'probes' => [
\Kanbino\Health\Probes\DatabaseProbe::class,
\Kanbino\Health\Probes\RedisProbe::class,
\Kanbino\Health\Probes\QueueProbe::class,
// Opt-in system probes:
// \Kanbino\Health\Probes\HorizonProbe::class, //
$this->app->bind(\Kanbino\Health\Probes\DiskProbe::class, fn () => new \Kanbino\Health\Probes\DiskProbe('/var/www', 90.0));
$this->app->bind(\Kanbino\Health\Probes\CpuProbe::class, fn () => new \Kanbino\Health\Probes\CpuProbe(120.0));
namespace App\Health;
use Kanbino\Health\Probes\HealthProbe;
use Kanbino\Health\Probes\ProbeResult;
class ScalewayReachableProbe implements HealthProbe
{
public function name(): string
{
return 'scaleway';
}
public function run(): ProbeResult
{
$ok = @fsockopen('s3.nl-ams.scw.cloud', 443, $err, $errstr, 2) !== false;
return $ok ? ProbeResult::ok() : ProbeResult::fail($errstr ?: 'unreachable');
}
}
// config/kanbino-health.php
'probes' => [
\Kanbino\Health\Probes\DatabaseProbe::class,
\Kanbino\Health\Probes\RedisProbe::class,
\Kanbino\Health\Probes\QueueProbe::class,
\App\Health\ScalewayReachableProbe::class, // your project-specific check
],
use Kanbino\Health\HealthResponse;
Route::get('/my-health', function (HealthResponse $response) {
return response()->json($response->build());
});