• Reading time ~ 1 min
  • 24.08.2022

Laravel Route Statistics is a package by @bilfeldt to log stats about users and teams usage of routes in a Laravel application. 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

Using Laravel's middleware, the package allows you to enable route logging globally, or you can enable it for individual route groups and routes via middleware:

Route::middleware(['routestatistics'])
    ->get('/example', /* ... */);

Finally, you can even enable logging via a request macro:

public function index(Request $request)
{
    $request->routeStatistics();
    // ...
    return view('example');
}

This package logs requests to the database with the following fields by default:

  • user_id - the user id if authenticated
  • team_id - the team id associated with the request (if available)
  • method - the HTTP method
  • route - the route name (if available) or the route URI
  • status - the HTTP status code
  • ip - the request IP
  • date - the date of the request stored as a datetime

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Comments

No comments yet
Yurij Finiv

Yurij Finiv

Full stack

ABOUT

Professional Fullstack Developer with extensive experience in website and desktop application development. Proficient in a wide range of tools and technologies, including Bootstrap, Tailwind, HTML5, CSS3, PUG, JavaScript, Alpine.js, jQuery, PHP, MODX, and Node.js. Skilled in website development using Symfony, MODX, and Laravel. Experience: Contributed to the development and translation of MODX3 i...

About author CrazyBoy49z
WORK EXPERIENCE
Contact
Ukraine, Lutsk
+380979856297