PHP code example of rakibuddin101 / laravel-server-lens
1. Go to this page and download the library: Download rakibuddin101/laravel-server-lens 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/ */
rakibuddin101 / laravel-server-lens example snippets
use Rakib\ServerLens\Facades\ServerLens;
$snapshot = ServerLens::snapshot(); // full metrics, health, and activity
$health = ServerLens::healthOnly(); // health checks only
$metrics = ServerLens::metricsOnly(); // CPU, RAM, Disk
use Rakib\ServerLens\Contracts\HealthCheck;
use Rakib\ServerLens\Data\CheckResult;
class StripeApiCheck implements HealthCheck
{
public function name(): string { return 'Stripe API'; }
public function run(): CheckResult
{
$start = microtime(true);
// your probe logic here
$ms = round((microtime(true) - $start) * 1000, 2);
return CheckResult::healthy("Reachable in {$ms} ms", $ms);
}
}
// In AppServiceProvider::boot()
use Rakib\ServerLens\Facades\ServerLens;
ServerLens::registerCheck(new StripeApiCheck());