PHPackages                             protonemedia/laravel-tracer - 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. protonemedia/laravel-tracer

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

protonemedia/laravel-tracer
===========================

v0.3.3(3y ago)21.2k3MITPHPPHP ^7.2 || ^8.0 || ^8.1

Since May 20Pushed 3y ago2 watchersCompare

[ Source](https://github.com/protonemedia/laravel-tracer)[ Packagist](https://packagist.org/packages/protonemedia/laravel-tracer)[ Docs](https://github.com/protonemedia/laravel-tracer)[ GitHub Sponsors](https://github.com/pascalbaljet)[ RSS](/packages/protonemedia-laravel-tracer/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (3)Versions (7)Used By (0)

\[WIP\] Laravel Tracer
======================

[](#wip-laravel-tracer)

Do not use in production!
-------------------------

[](#do-not-use-in-production)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2778938241153a7abd653b94eddd7b2b30d683c4686647ddab545e7bb215d5eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70726f746f6e656d656469612f6c61726176656c2d7472616365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/protonemedia/laravel-tracer)[![Build Status](https://camo.githubusercontent.com/d7f83239caa4ff5bbd45d46f3444251bb35aa17c06335727a8e56eb165574c8f/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f70726f746f6e656d656469612f6c61726176656c2d7472616365722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/protonemedia/laravel-tracer)[![Quality Score](https://camo.githubusercontent.com/e56c3a330100a14d19ad4e48fe56ca656bfd44bd23b833a812e7faf79ddd14ed/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f70726f746f6e656d656469612f6c61726176656c2d7472616365722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/protonemedia/laravel-tracer)[![Total Downloads](https://camo.githubusercontent.com/60f83e246581ba8a2b39417679f18ede85226914b821f9eac640c26599c8f873/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70726f746f6e656d656469612f6c61726176656c2d7472616365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/protonemedia/laravel-tracer)

A package to log request of authenticated users by bundling and qualifying routes.

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

[](#installation)

You can install the package via composer:

```
composer require protonemedia/laravel-tracer
```

Publish the migration and config file and then run the migration.

```
php artisan vendor:publish
php artisan migrate
```

Usage
-----

[](#usage)

Add the `QualifyRoute` middleware to your Route Middleware stack:

```
class Kernel extends \Illuminate\Foundation\Http\Kernel
{
    protected $routeMiddleware = [
        // ...
        'qualify' => \ProtoneMedia\LaravelTracer\Middleware\QualifyRoute::class,
        // ...
    ];
}
```

Add the `TraceUser` middleware to the routes or groups you want to trace, for example in the `web.php` routes file:

```
use ProtoneMedia\LaravelTracer\Middleware\TraceUser;

Route::group(['middleware' => [TraceUser::class]], function () {
    Route::get('home', 'HomeController');

    Route::get('settings', 'SettingsController')->name('settings.show');

    Route::get('privacy-policy', 'PrivacyPolicyController')->name('privacyPolicy.show')->middleware('qualify:terms');

    Route::get('profile/notifications', 'NotificationsController')->name('notifications.index')->middleware('qualify:notifications,60');

    Route::group(['middleware' => ['qualify:finance']], function () {
        Route::get('invoices', 'InvoicesController@index')->name('invoices.index');
        Route::get('invoices/{id}', 'InvoicesController@show')->name('invoices.show');
    });

    Route::get('machine/{id}', 'MachineController');
    Route::get('rack/{id}', 'RackController')->middleware('qualify:rack');
    Route::get('server/{id}', 'ServerController')->middleware('qualify:server.{id}');
});
```

Now every request in this example will be logged to the `user_requests` table. You can use the `ProtoneMedia\LaravelTracer\UserRequest` model the retrieve the log entries.

### Qualify routes

[](#qualify-routes)

As you can see there are some example routes added to the group of routes we want to trace. Let's explain how each route will be qualified.

- A GET request to `/home` will simply be qualified as `home` since it has no name and no qualifier.
- A GET request to `/settings` will be qualified as `settings.show` because it has a name but still no qualifier.
- A GET request to `/privacy-policy` will be qualified as `terms`, this has been accomplished with the `qualify` middleware.

### Rate limiting

[](#rate-limiting)

- A GET request to `/profile/notifications` will be qualified as `notifications` and as you can see, the `qualify` middleware was given a second parameter. This is the number of seconds between each log of this qualifier. When a user visits this route more than once in 60 seconds, it will be stored as 1 request.

### Grouped qualifiers

[](#grouped-qualifiers)

- A GET request to both `/invoices` and `/invoices/1` will be qualified as `finance`.

### Parameters

[](#parameters)

- A GET request `/machine/1` will be qualified as `machine/1`, it has no name and no qualifier so the `path` will be used as qualifier.
- A GET request to both `/rack/1` and `/rack/2` will be qualified as `rack`. Though the route has a parameter, the qualifier will be used.
- A GET request to `/server/1` will be qualified as `server.1`. The parameter in the qualifier will be replaced with the actual value used in the path.

### Qualify from the controller

[](#qualify-from-the-controller)

This package adds two macros to `Illuminate\Http\Request`. The first one is `qualifyAs`. Just as the `QualifyRoute` middleware this method takes two parameters. The first parameter is the name and the second paramater (optional) is the number seconds to be used by the Rate Limiter. From your controller you could qualify the route using the `Request` object or by using the `request()` helper method. The other macro is `qualifiedRoute` which is a getter for the `QualifiedRoute` instance.

```
use Illuminate\Http\Request;

class TicketsController extends Controller
{
    public function index()
    {
        request()->qualifyAs('tickets', 60);
    }

    public function show(Request $request, $id)
    {
        $request->qualifyAs('tickets');
    }

    public function delete(Request $request, $id)
    {
        $qualifiedRoute = $request->qualifiedRoute();

        $qualifiedRoute->name();
        $qualifiedRoute->secondsBetweenLogs();
    }
}
```

### Config

[](#config)

The config file consists of only two options. The first option is `seconds_between_logs` which can be used to set a default for the Rate Limiter. The second option is `should_trace_user` where you can specify a class@method which should return a boolean that specifies wether to trace or not. It takes two parameters: $request and $response:

```
// config/laravel-tracer.php

return [
    'seconds_between_logs' => 120,

    'should_trace_user' => 'MyClass@shouldTrace',
];
```

```
// MyClass.php

use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class MyClass
{
    public function shouldTrace(Request $request, Response $response): bool
    {
        return !$request->user()->isAdmin();
    }
}
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Pascal Baljet](https://github.com/protonemedia)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~292 days

Total

5

Last Release

1381d ago

PHP version history (3 changes)v0.1.0PHP ^7.2

v0.3.2PHP ^7.2 || ^8.0

v0.3.3PHP ^7.2 || ^8.0 || ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8403149?v=4)[Pascal Baljet](/maintainers/pascalbaljet)[@pascalbaljet](https://github.com/pascalbaljet)

---

Top Contributors

[![pascalbaljet](https://avatars.githubusercontent.com/u/8403149?v=4)](https://github.com/pascalbaljet "pascalbaljet (17 commits)")

---

Tags

laravelphpprotonemedialaravel-tracer

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/protonemedia-laravel-tracer/health.svg)

```
[![Health](https://phpackages.com/badges/protonemedia-laravel-tracer/health.svg)](https://phpackages.com/packages/protonemedia-laravel-tracer)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[beyondcode/laravel-server-timing

Add Server-Timing header information from within your Laravel apps.

5712.0M1](/packages/beyondcode-laravel-server-timing)[rollbar/rollbar-laravel

Rollbar error monitoring integration for Laravel projects

14110.4M7](/packages/rollbar-rollbar-laravel)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[kitloong/laravel-app-logger

Laravel log for your application

101.2M8](/packages/kitloong-laravel-app-logger)[label84/laravel-auth-log

Log user authentication actions in Laravel.

3654.0k](/packages/label84-laravel-auth-log)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
