bilfeldt/laravel-route-statistics
Logs Laravel route usage statistics by recording and aggregating requests/responses per route, user, and timeframe (hour/day/month) to minimize database storage. Helps spot heavy users, high-traffic endpoints, and suspicious unauthenticated activity.
team_id) and conditional logging (via middleware/request macros), allowing integration with existing auth/team systems or selective instrumentation.bilfeldt/laravel-request-logger, which may introduce indirect complexity (e.g., queued logging, custom loggers).route_statistics table) with fields like user_id, team_id, route, parameters, and status. No foreign key constraints by default, requiring manual setup if referencing custom user/team models.route:stats and route:unused offer quick insights but assume the package is already integrated.user() relationship assumes Laravel’s App\Models\User. Polyfill required if using custom auth systems (e.g., Spatie\Permission or Brefink\Teams).id fields).failed_jobs table./api/v1/*)?user() relationship be configured?user_id, route, date)?User model. For custom auth (e.g., Brefink\Teams), configure the user_model in config/route-statistics.php.team_id), useful for SaaS apps.composer.json to target the correct Laravel/PHP version (e.g., "bilfeldt/laravel-route-statistics": "^4.0" for Laravel 10+).composer update bilfeldt/laravel-route-statistics.php artisan vendor:publish --provider="Bilfeldt\LaravelRouteStatistics\LaravelRouteStatisticsServiceProvider" --tag="migrations"
php artisan migrate
user_id, route, date).php artisan vendor:publish --provider="Bilfeldt\LaravelRouteStatistics\LaravelRouteStatisticsServiceProvider" --tag="config"
config/route-statistics.php for:
user_model (if not App\Models\User).queue_connection (if not using default).log_parameters (disable if not needed).bootstrap/app.php:
$middleware->prepend(\Bilfeldt\LaravelRouteStatistics\Http\Middleware\RouteStatisticsMiddleware::class);
Route::middleware(['routestatistics'])->group(function () {
// Critical routes only
});
$request->routeStatistics();
route_statistics table.php artisan route:stats --route="dashboard"
php artisan route:unused
RouteStatisticsMiddleware runs after request parsing but before response generation.Request class. No issues with API resources or form requests.Brefink\Teams or similar if team_id is added to context.route:stats to validate data collection.user_id, route, or date.route_statistics in database backups if retention >7 days.config/route-statistics.php. Easy to override via environment variables.How can I help you explore Laravel packages today?