Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Auditor Laravel Package

damienharper/auditor

View on GitHub
Deep Wiki
Context7

Quick Start Guide

Set up the auditor core and connect a provider

auditor is a framework-agnostic audit library. It handles orchestration — event dispatching, user attribution, security — while providers handle storage and querying.

flowchart LR
    A["1️⃣ Configure<br/>Auditor"] --> B["2️⃣ Register<br/>a Provider"]
    B --> C["3️⃣ Mark entities<br/>as Auditable"]
    C --> D["🎉 Done!"]

1️⃣ Configure the Auditor

The Auditor class is the central registry. Configure it once at bootstrap time.

<?php

use DH\Auditor\Auditor;
use DH\Auditor\Configuration;
use DH\Auditor\User\User;
use Symfony\Component\EventDispatcher\EventDispatcher;

$configuration = new Configuration([
    'enabled'  => true,
    'timezone' => 'UTC',
]);

// Optional: tell auditor who is making changes
$configuration->setUserProvider(function (): ?User {
    return new User((string) $currentUser->getId(), $currentUser->getUsername());
});

// Optional: provide IP + firewall context
$configuration->setSecurityProvider(function (): array {
    return [$request->getClientIp(), 'main'];
});

$auditor = new Auditor($configuration, new EventDispatcher());

2️⃣ Register a Provider

A provider connects auditor to a specific storage technology. Each provider has its own setup (services, schema, etc.) — refer to your provider's documentation.

$auditor->registerProvider($provider);
Provider Package Storage
DoctrineProvider auditor-doctrine-provider Doctrine ORM / DBAL

3️⃣ Mark Entities as Auditable

Use the #[Auditable] attribute on any class you want tracked. #[Ignore] excludes individual fields; #[Security] restricts who can view the audit entries; #[DiffLabel] attaches a human-readable label to a property's raw value in the diff.

<?php

namespace App\Entity;

use DH\Auditor\Attribute\Auditable;
use DH\Auditor\Attribute\DiffLabel;
use DH\Auditor\Attribute\Ignore;
use DH\Auditor\Attribute\Security;

#[Auditable]
#[Security(view: ['ROLE_ADMIN'])]
class User
{
    private string $email;

    #[Ignore]
    private string $password;  // this field will never appear in audit diffs

    #[DiffLabel(resolver: StatusLabelResolver::class)]
    private int $status;      // raw value stored alongside a human-readable label
}

The attributes are part of auditor core (DH\Auditor\Attribute\) and work with any provider. How a provider discovers and registers auditable entities is provider-specific — see your provider's documentation for details.

🎉 Done!

From this point, every flush that touches an auditable entity will produce an audit entry. Refer to your provider's quick start for schema setup and reading audit entries back:

DoctrineProvider Quick Start


What's Next?

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui