1. Go to this page and download the library: Download leventcz/laravel-top 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/ */
leventcz / laravel-top example snippets
php artisan top
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'),
];
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();
bash
php artisan vendor:publish --tag="top"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.