A lightweight Laravel monitoring package that provides comprehensive HTTP traffic insights without database overhead.
Traffic is a filesystem-based Laravel monitoring solution that captures detailed request analytics, performance metrics, and user insights. Unlike database-driven alternatives, it uses efficient file storage with automatic cleanup, ensuring minimal impact on your application's performance.
- HTTP Traffic Logging - Complete request/response monitoring
- Performance Metrics - Route-level execution time analysis
- Flexible Configuration - Monitor all routes or specific endpoints
- RESTful API - Query your analytics data programmatically
- Zero Database Impact - Filesystem storage with automatic cleanup
- Device & User Analytics - Comprehensive visitor insights
composer require fyz/trafficOptional: Publish the configuration file to customize settings
php artisan vendor:publish --tag=trafficConfigure monitoring behavior in config/traffic.php:
- global:
true/false- Monitor all application routes - routes:
true/false- Enable selective monitoring via middleware
Set global: true in config to monitor all routes automatically.
Use the traffic middleware on specific routes:
// Monitor a route group
Route::middleware(['traffic'])->group(function () {
Route::get('/api/users', [UserController::class, 'index']);
Route::post('/api/users', [UserController::class, 'store']);
});
// Monitor a single route
Route::get('/dashboard', [DashboardController::class, 'index'])
->middleware(['traffic']);Access your analytics via RESTful endpoints:
GET|POST /traffic/logs/{resource}GET|POST /traffic/logs/{resource}/since/{days}Available Resources:
requests- HTTP request logsperformance- Route execution metricsdevices- Device and browser analyticsusers- User behavior insights
# Get today's requests
curl https://yourapp.com/traffic/logs/requests
# Get performance data from last 7 days
curl https://yourapp.com/traffic/logs/performance/since/7
# Get user analytics from last 30 days
curl https://yourapp.com/traffic/logs/users/since/30