PHPackages                             bilfeldt/laravel-route-statistics - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. bilfeldt/laravel-route-statistics

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

bilfeldt/laravel-route-statistics
=================================

Log statistics about route usage per user/team

v4.3.0(2mo ago)240132.9k↑21.6%25[1 PRs](https://github.com/bilfeldt/laravel-route-statistics/pulls)2MITPHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0CI passing

Since Apr 19Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/bilfeldt/laravel-route-statistics)[ Packagist](https://packagist.org/packages/bilfeldt/laravel-route-statistics)[ Docs](https://github.com/bilfeldt/laravel-route-statistics)[ GitHub Sponsors](https://github.com/bilfeldt)[ RSS](/packages/bilfeldt-laravel-route-statistics/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (26)Used By (2)

Log Laravel route usage statistics
==================================

[](#log-laravel-route-usage-statistics)

[![bilfeldt/laravel-route-statistics](art/banner.png)](art/banner.png)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2b96111e8583ac7bf9c0284b653e5792e4c4ff51308b41ab9d96d7d34e1f12e6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62696c66656c64742f6c61726176656c2d726f7574652d737461746973746963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bilfeldt/laravel-route-statistics)[![GitHub Tests Action Status](https://camo.githubusercontent.com/b8793e5577cadee771ca6e091dd577d5a1e761ee75955d64d9cbd840b4f7c01e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f62696c66656c64742f6c61726176656c2d726f7574652d737461746973746963732f72756e2d74657374732e796d6c)](https://github.com/bilfeldt/laravel-route-statistics/actions?query=workflow%3Arun-tests+branch%3Amaster)[![StyleCI Code Style Status](https://camo.githubusercontent.com/17f2875ab0f7dd4cf7582c0f83eb71510e239d9ba42529bb9ae2bd314d6e84e4/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3335393131363337362f736869656c64)](https://github.styleci.io/repos/359116376/shield)[![Total Downloads](https://camo.githubusercontent.com/2df51605f51045aeec46ec6725b1df891c8436eb58c5327a37e9d96c6a2ae3a4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62696c66656c64742f6c61726176656c2d726f7574652d737461746973746963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bilfeldt/laravel-route-statistics)

Log Laravel requests and responses for statistical purposes and optionally aggregate by hours/days/months for minimal db requirements.

VersionLaravelPHP1.\*8.\* | 9.\*7.4.\* | 8.0.\* | 8.1.\*2.\*10.\*8.1.\* | 8.2.\*3.\*11.\*8.1.\* | 8.2.\* | 8.3.\*4.\*10.\* | 11.\* | 12.\*8.2.\* | 8.3.\* | 8.4.\*Description
-----------

[](#description)

Log requests and group them together for aggregated statistics of route usage. Grouping requests by route means that this package saves a minimum of data to the database and subsequent purging of old data can improve this even further.

This package lets you:

- See how much each user uses the application and what part of the application they use
- See if any unauthenticated users are making a lot of requests to your application

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require bilfeldt/laravel-route-statistics
```

You can publish and run the migrations with:

```
php artisan vendor:publish --provider="Bilfeldt\LaravelRouteStatistics\LaravelRouteStatisticsServiceProvider" --tag="migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Bilfeldt\LaravelRouteStatistics\LaravelRouteStatisticsServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

There are a few ways to enable logging of route usage:

### Enable global logging

[](#enable-global-logging)

This will enable site-wide logging and although being the easiest implementation this might not be exactly what you are looking for (consider only logging relevant routes using the [middleware](#enable-via-middleware) approach below)

Simply add `RouteStatisticsMiddleware` as a global middleware in `bootstrap/app.php`

```
// bootstrap/app.php
