chrishenrique/laravel-requests-monitor
Lightweight Laravel package to monitor, log, and analyze HTTP requests and custom app actions. Supports middleware auto-tracking, manual event registration, dedicated DB connection, configurable retention/pruning, and works with Laravel 7+ (PHP 7.4/8+).
A lightweight Laravel package to monitor, log, and analyze HTTP requests and custom application actions.
Designed to be simple, extensible, and database-agnostic, it works seamlessly with legacy Laravel versions (7.x) and modern PHP versions.
Install the package via Composer:
composer require chrishenrique/laravel-requests-monitor
php artisan vendor:publish --tag=requests-monitor-config
The config file will be available at:
config/requests-monitor.php
It is recommended to use a dedicated database or schema.
Create a database and configure a new connection named requests-monitor in config/database.php:
'connections' => [
'requests-monitor' => [
'driver' => 'mysql',
'host' => env('DB_MONITOR_HOST', '127.0.0.1'),
'port' => env('DB_MONITOR_PORT', '3306'),
'database' => env('DB_MONITOR_DATABASE', 'requests_monitor'),
'username' => env('DB_MONITOR_USERNAME', 'root'),
'password' => env('DB_MONITOR_PASSWORD', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
],
],
Publish the migrations:
php artisan vendor:publish --tag=requests-monitor-migrations
Run them:
php artisan migrate
use ChrisHenrique\RequestsMonitor\Middlewares\RequestMonitorMiddleware;
$middleware->appendToGroup('web', [
RequestMonitorMiddleware::class,
]);
In app/Http/Kernel.php:
protected $middlewareGroups = [
'web' => [
\ChrisHenrique\RequestsMonitor\Middlewares\RequestMonitorMiddleware::class,
],
];
Register the prune command in app/Console/Kernel.php:
protected function schedule(Schedule $schedule)
{
$schedule->command('requests-monitor:prune')->daily();
}
You may also run it manually:
php artisan requests-monitor:prune
You can manually register application-specific actions:
registerAction('billet.download', session('customer'));
This is useful for tracking business logic events that are not directly related to HTTP requests.
Contributions are welcome!
Please open an issue or submit a pull request.
The MIT License (MIT). Please see the LICENSE file for more information.
How can I help you explore Laravel packages today?