Увійти Реєстрація
Блог Серії
Кар'єра
Вакансії Компанії
Навчання
Документація Співбесіди Тестування Відео
Екосистема
Пакети Ресурси Проєкти Події
Інше
Про нас

Laravel Top

leventcz/laravel-top
v1.3.0 13 582 121.8k 1 травня 2026
На GitHub

Реал-тайм моніторинг Laravel-додатків прямо з командного рядка.

3

Поділитись

README

Latest Version on Packagist GitHub Tests Action Status Licence

leventcz%2Flaravel-top | Trendshift

Real-time monitoring with Laravel Top

php artisan top

Top provides a lightweight solution for 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 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.

Top only listens to events from incoming requests, so metrics from operations performed via queues or commands are not reflected.

Since the data is stored in Redis, the output of the top command reflects data from all application servers, not just the server where you run the command.

Installation

Compatible with Laravel 10+ and Laravel Octane.

Requires PHP 8.2+ | Redis 5.0+

composer require leventcz/laravel-top

Configuration

You can publish the config file with:

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

return [

    /*
    |--------------------------------------------------------------------------
    | Redis Connection
    |--------------------------------------------------------------------------
    |
    | Specify the Redis database connection from config/database.php
    | that Top will use to save data.
    | The default value is suitable for most applications.
    |
    */

    'connection' => env('TOP_REDIS_CONNECTION', 'default'),

    /*
    |--------------------------------------------------------------------------
    | Recording Mode
    |--------------------------------------------------------------------------
    |
    | Determine when Top should record application metrics based on this value.
    | By default, Top only listens to your application when it is running.
    | If you want to access metrics through the facade, you can select the "always" mode.
    |
    | Available Modes: "runtime", "always"
    |
    */

    'recording_mode' => env('TOP_RECORDING_MODE', 'runtime'),
];


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;

// Retrieve HTTP request metrics
$requestSummary = Top::http();
$requestSummary->averageRequestPerSecond;
$requestSummary->averageMemoryUsage;
$requestSummary->averageDuration;

// Retrieve database query metrics
$databaseSummary = Top::database();
$databaseSummary->averageQueryPerSecond;
$databaseSummary->averageQueryDuration;

// Retrieve cache operation metrics
$cacheSummary = Top::cache();
$cacheSummary->averageHitPerSecond;
$cacheSummary->averageMissPerSecond;
$cacheSummary->averageWritePerSecond;

// Retrieve the top 20 busiest routes
$topRoutes = Top::routes();
$topRoutes->each(function(Route $route) {
    $route->uri;
    $route->method;
    $route->averageRequestPerSecond;
    $route->averageMemoryUsage;
    $route->averageDuration;
});

// Force Top to start recording for the given duration (in seconds)
Top::startRecording(int $duration = 5);

// Force Top to stop recording
Top::stopRecording();

// Check if Top is currently recording
Top::isRecording();

Testing

composer test

License

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

Коментарі

Увійдіть, щоб залишити коментар

Будьте першим, хто залишить коментар!

Схожі пакети

Laravel Debugbar

barryvdh/laravel-debugbar

Інтеграція PHP Debugbar у Laravel для відлагодження та аналізу роботи додатку.

19,281 v4.4.2 13 8

Pest

pestphp/pest

Тестовий фреймворк з лаконічним синтаксисом поверх PHPUnit: тести описуються функціями замість класів. Має паралельний запуск, тести архітектури, покриття і мутаційне тестування.

11,667 v5.1.1 2

Rector

rector/rector

Автоматичний рефакторинг і оновлення коду: піднімає синтаксис до нової версії PHP, застосовує набори правил для Laravel і виправляє застарілі API масово, а не вручну по файлах.

10,405 2.6.3 1

Larastan

larastan/larastan

Статичний аналіз для Laravel: вчить PHPStan розуміти фасади, магічні методи Eloquent і контейнер. Ловить помилки типів і неіснуючі методи до того, як код дійде до тестів.

6,482 v3.10.0 13 1

Larastan

nunomaduro/larastan

Larastan — це розширення phpstan/phpstan для Laravel, яке дозволяє виявляти помилки у коді без його запуску.

6,482 v3.10.0 13 8

Laravel Backup

spatie/laravel-backup

Пакет для створення резервних копій вашого Laravel-додатку.

6,018 10.3.2 13 9