laravel-server-lens maintained by rakibuddin101
Laravel Server Lens
A plug-and-play server observability and traffic monitoring dashboard for Laravel. Get live CPU, RAM, disk metrics, service health checks, a real-time request feed with bot detection, and IP blocking — all in one embeddable dashboard with no external services and no build step required.

Installation
You can install the package via Composer:
composer require rakibuddin101/laravel-server-lens
Run the installer to publish config, migrations, and assets:
php artisan server-lens:install
Run the migrations:
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="server-lens-config"
You can publish the views to customise the dashboard:
php artisan vendor:publish --tag="server-lens-views"
Usage
Visit the dashboard at /ops (or whatever route_prefix you configured):
http://your-app.test/ops
Programmatic access
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
Custom health checks
Implement the HealthCheck contract and register it in a service provider:
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());
Artisan commands
# Run all health checks and print results
php artisan server-lens:check
# Delete traffic logs older than prune_after_days
php artisan server-lens:prune
# Block an IP address (add --hours=N for a temporary block)
php artisan server-lens:block 203.0.113.42
php artisan server-lens:block 203.0.113.42 --hours=24
# Remove an IP block
php artisan server-lens:unblock 203.0.113.42
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.