Package

Leventcz Laravel Top

Real-time monitoring straight from the command line for Laravel applications.

Package

leventcz/laravel-top

View on GitHub →

Real-time monitoring with Laravel Top

php artisan top

Top provides real-time monitoring directly from the command line for Laravel applications. It is designed for production environments, enabling you to effortlessly track essential metrics and identify the busiest routes.

How it works?

Top listens to Laravel events and saves aggregated data to Redis hashes behind the scenes to calculate metrics. The aggregated data is stored with a short TTL, ensuring that historical data is not retained and preventing Redis from becoming overloaded. During display, metrics are calculated based on the average of the last 5 seconds of data.

Installation

Compatible with Laravel 10, Laravel 11, and Laravel Octane.

Requires PHP 8.2+ | Redis 5.0+

composer require leventcz/laravel-top

Configuration

By default, Top uses the default Redis connection. To change the connection, you need to edit the configuration file.

You can publish the config file with:

php artisan vendor:publish --tag="top"
<?php

return [
    /*
     * Provide a redis connection from config/database.php
    */
    'connection' => env('TOP_REDIS_CONNECTION', 'default')
];

Facade

If you want to access metrics in your application, you can use the Top facade.

<?php

use Leventcz\Top\Facades\Top;
use Leventcz\Top\Data\Route;

$requestSummary = Top::http();
$requestSummary->averageRequestPerSecond;
$requestSummary->averageMemoryUsage;
$requestSummary->averageDuration;

$databaseSummary = Top::database();
$databaseSummary->averageQueryPerSecond;
$databaseSummary->averageQueryDuration;

$cacheSummary = Top::cache();
$cacheSummary->averageHitPerSecond;
$cacheSummary->averageMissPerSecond;
$cacheSummary->averageWritePerSecond;

$topRoutes = Top::routes();
$topRoutes->each(function(Route $route) {
    $route->uri;
    $route->method;
    $route->averageRequestPerSecond;
    $route->averageMemoryUsage;
    $route->averageDuration;
})

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

composer test

License

The MIT License (MIT). Please see License File for more information.

Leventcz Laravel Top Related Articles

Real Time Command Line Monitoring With Laravel Top image

Real Time Command Line Monitoring With Laravel Top

Read article
The Top Five Laravel Community Editor Themes image

The Top Five Laravel Community Editor Themes

Read article
Top 10 Laravel Audit Security Issues image

Top 10 Laravel Audit Security Issues

Read article
Top 6 MySQL Database Management Struggles for Laravel Developers (And Smart Fixes) image

Top 6 MySQL Database Management Struggles for Laravel Developers (And Smart Fixes)

Read article
Laravel News top 10 posts of 2022 image

Laravel News top 10 posts of 2022

Read article
Speed Up Laravel on Top of Swoole image

Speed Up Laravel on Top of Swoole

Read article

Let your users buy domains without leaving your app

If your Laravel app gives users a site, a storefront, or a workspace, they’ll eventually want their own domain. The name.com API lets them search, register, and connect one without leaving your product. It’s a clean REST API, so Laravel’s HTTP client is all you need.

Let your users buy domains without leaving your app

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum