Looking to hire Laravel developers? Try LaraJobs

nard-laravel maintained by sadeim

Description
Zero-config activity tracking for Laravel apps. Automatically tracks HTTP requests, auth events, model changes, and queue jobs. Powered by Nard Agent (https://nard.sadeim.com).
Author
Last update
2026/05/17 17:08 (dev-main)
License
Downloads
1

Comments
comments powered by Disqus

Nard for Laravel

Latest Version Tests License: MIT

Zero-config activity tracking for Laravel applications.

Install the package and Nard automatically records what happens in your app — HTTP requests, logins, every Eloquent model change, and queue jobs — then streams it to the local Nard Agent, which forwards it to Sadeim Central. No code changes, no manual instrumentation.

Why it's safe to leave on

  • Zero added latency. HTTP tracking runs in terminable middleware — events are recorded and sent after the response has already been delivered to the visitor.
  • In-memory buffering. Recording an event is just an array append (microseconds). The actual send to the agent happens once, post-response.
  • Loopback only. The package talks solely to the local agent on 127.0.0.1; every send is best-effort and failure is swallowed, so tracking can never break or slow your app.
  • Sensitive data is redacted before anything leaves the server — see SECURITY.md.

Requirements

  • PHP 8.1+
  • Laravel 10, 11, or 12
  • A running Nard Agent on the same server (listening on 127.0.0.1:8765 by default)

Installation

composer require sadeim/nard-laravel

The service provider and the Nard facade are auto-discovered. That's it — tracking is now on.

Optionally publish the config file to tune behaviour:

php artisan vendor:publish --tag=nard-config

Configuration

All settings live in config/nard.php and can be driven by environment variables.

Key Env Default Purpose
enabled NARD_ENABLED true Master on/off switch.
agent_url NARD_AGENT_URL http://127.0.0.1:8765 Local agent receiver.
timeout NARD_TIMEOUT 1.0 Connect/total timeout (seconds) for the post-response send.
track.http NARD_TRACK_HTTP true Track every HTTP request.
track.auth NARD_TRACK_AUTH true Track login / logout / failed / registered.
track.models NARD_TRACK_MODELS true Track Eloquent create / update / delete.
track.queue NARD_TRACK_QUEUE true Track queue job processed / failed.
sample_rate NARD_SAMPLE_RATE 1.0 Fraction of HTTP requests to record (0.0–1.0).
max_events_per_request NARD_MAX_EVENTS 500 Per-request buffer cap.
sanitize_fields see config Field names redacted from every payload.
exclude_models DatabaseNotification Eloquent classes to skip.
exclude_routes telescope*, horizon*, … Request paths to skip (Request::is() patterns).

To turn everything off without uninstalling:

NARD_ENABLED=false

On a very high-traffic app you can sample HTTP requests (auth, model and queue events are always recorded in full):

NARD_SAMPLE_RATE=0.2

Automatic tracking

Once installed, the following are captured with no further work:

  • HTTP — method, path, status code, duration, source IP, user agent.
  • Authauth.login, auth.logout, auth.failed, auth.registered.
  • Modelsmodel.created / model.updated / model.deleted, with the changed scalar attributes (sensitive ones redacted).
  • Queuequeue.processed and queue.failed.

Manual tracking

Use the Nard facade for named business events that span more than one model — automatic tracking already covers the rest.

use Sadeim\Nard\Facades\Nard;

Nard::track()

Nard::track('checkout.completed', [
    'target_type' => 'Order',
    'target_id'   => $order->id,
    'payload'     => ['total' => $order->total, 'currency' => 'USD'],
]);

Nard::activity() — fluent builder

Nard::activity('checkout.completed')
    ->actor($user)                       // or ->actorId('42', 'Sara')
    ->target('Order', $order->id)
    ->targetName("Order #{$order->id}")
    ->action('completed')
    ->payload(['total' => $order->total])
    ->with('currency', 'USD')
    ->record();

If no actor is set, the currently authenticated user is used automatically.

Nard::batch()

In long-running processes (console commands, daemons) there is no HTTP response to flush on. Wrap a unit of work in batch() to record it and immediately ship whatever it tracked:

Nard::batch(function () {
    foreach ($invoices as $invoice) {
        $invoice->markPaid();                 // tracked automatically
        Nard::track('invoice.reconciled', ['target_id' => $invoice->id]);
    }
});

Security

Sensitive values (passwords, tokens, card numbers, …) are redacted from every payload before it leaves your server, recursively and case-insensitively. The list is configurable. See SECURITY.md for the full default set and how to extend or exclude.

Testing

composer install
vendor/bin/phpunit

Links

License

The MIT License (MIT). See LICENSE.