Search by

muhammad-nawlo / route-tracker

Muhammad-Nawlo

Track usage and hits of Laravel routes automatically with this simple package.

Package info

github.com/Muhammad-Nawlo/route-tracker

Homepage

pkg:composer/muhammad-nawlo/route-tracker

Fund package maintenance!

Muhammad-Nawlo

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 3

v1.0.4 2025-06-12 21:03 UTC

This package is auto-updated.

Last update: 2026-10-08 13:04:44 UTC


README

Tests License: MIT

Find out which routes in your Laravel app are actually used. Route Tracker counts hits and records the last-used time for every route, so you can spot dead endpoints before you delete or refactor them.

Features

  • Zero setup: the middleware registers itself on the web group
  • Records hit count and last-used timestamp per route (route name, or path for unnamed routes)
  • Stores data as JSON on your default filesystem disk, so it works with local storage, S3 and any other Laravel disk
  • php artisan route:usage prints a usage table
  • Switch it off with one environment variable
  • Supports Laravel 10, 11 and 12 on PHP 8.0+

Installation

composer require muhammad-nawlo/route-tracker

The service provider is auto-discovered. Optionally publish the config:

php artisan vendor:publish --provider="MuhammadNawlo\RouteTracker\RouteTrackerServiceProvider" --tag=config

Usage

Browse your app as normal, then run:

php artisan route:usage
+-----------------+------+---------------------+
| Route           | Hits | Last Used           |
+-----------------+------+---------------------+
| dashboard       | 42   | 2026-10-08 14:03:11 |
| profile.edit    | 7    | 2026-10-07 09:12:45 |
| reports/export  | 1    | 2026-09-30 17:40:02 |
+-----------------+------+---------------------+

The raw data lives in route-usage.json on the default disk.

To track API routes too, add the middleware to the api group yourself:

// bootstrap/app.php (Laravel 11+)
->withMiddleware(function (Middleware $middleware) {
    $middleware->api(append: [
        \MuhammadNawlo\RouteTracker\Middleware\TrackRouteUsage::class,
    ]);
})

Configuration

// config/route-tracker.php
return [
    'enabled' => env('ROUTE_TRACKER_ENABLED', true),
];

Set ROUTE_TRACKER_ENABLED=false to turn tracking off.

Every request reads and writes one JSON file, so the package is best suited to development, staging and low-to-medium traffic apps.

Testing

composer test

Changelog

See CHANGELOG.md.

License

MIT. See LICENSE.md.