roky / laravel-route-analytics
Dead-simple route usage tracking for Laravel — find unused and slow routes in minutes.
Package info
github.com/roky484812/laravel-route-analytics
pkg:composer/roky/laravel-route-analytics
v1.0.0
2026-06-04 18:24 UTC
Requires
- php: ^8.2
- illuminate/support: ^11.0|^12.0|^13.0
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^9.0
- phpunit/phpunit: ^11.0|^12.0
README
Dead-simple route usage tracking for Laravel — find unused and slow routes in minutes.
Features
- 🚀 Zero configuration - Works out of the box
- 📊 Beautiful dashboard - Clean, responsive UI with filtering and sorting
- 🔍 Find unused routes - Identify routes that are never hit
- ⚡ Track performance - Monitor average and max response times
- 🛠️ CLI commands - Automate reporting and maintenance
- 💾 Minimal overhead - Lightweight database storage with atomic updates
Installation
composer require roky/laravel-route-analytics php artisan migrate
That's it! Visit /route-analytics to see your dashboard.
Dashboard
Access the analytics dashboard at /route-analytics:
- Overview stats: Tracked routes, total hits, unused routes
- Sortable table: Click column headers to sort
- Filters: All, Unused, Slow (>200ms)
- Real-time data: Automatically updates as traffic flows
CLI Commands
View top routes
php artisan route:analytics:report
Find unused routes
php artisan route:analytics:report --unused
Find slow routes
php artisan route:analytics:report --slow=200
Clear all data
php artisan route:analytics:flush
Prune old data
php artisan route:analytics:prune --days=90
Configuration
Publish the configuration file:
php artisan vendor:publish --tag=route-analytics-config
Available options in config/route-analytics.php:
return [ 'enabled' => true, // Enable/disable tracking 'driver' => 'database', // Storage driver 'table' => 'route_analytics', // Database table name 'middleware' => ['web'], // Dashboard middleware 'path' => 'route-analytics', // Dashboard path ];
Protect the Dashboard
Add authentication to the dashboard:
'middleware' => ['web', 'auth'],
How It Works
- Middleware intercepts every request and records route key, duration, and timestamp
- Data is aggregated in the database (hits, average/max/min times)
- Dashboard and CLI commands read from the aggregated data
- Minimal performance impact - single atomic DB write per request
License
MIT