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


// config/server-lens.php
'middleware' => ['web', 'auth', 'can:admin'],   // Laravel Gate
'middleware' => ['web', 'auth', 'role:admin'],   // Spatie Permissions / your own middleware

'middleware' => ['web', 'auth'],

'middleware' => ['web'],

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());
bash
php artisan server-lens:install
bash
php artisan migrate
bash
php artisan vendor:publish --tag="server-lens-config"
bash
php artisan vendor:publish --tag="server-lens-views"