Docs / Getting Started / Installation

Installation

Install the bundle and record your first entry.

Requirements

The bundle needs PHP 8.2 or later, Symfony 6.4, 7.x or 8.x, and symfony/framework-bundle. Each source and output needs its own package. See Sources and Outputs.

Install the bundle

The bundle is a private package on Private Packagist. Add the repository to your project:

terminal
$ composer config repositories.private-packagist composer https://repo.packagist.com/symfonycorp/

Add your Private Packagist token to your global Composer configuration. Do not commit the token:

terminal
$ composer config --global --auth http-basic.repo.packagist.com token <TOKEN>

Then install the bundle:

terminal
$ composer require symfonycorp/audit-log

Symfony Flex registers the bundle. Without Flex, add it to config/bundles.php:

config/bundles.php
SymfonyCorp\AuditLog\AuditLogBundle::class => ['all' => true],

Quick start

This example records each change of a Doctrine entity in a SQL table. It needs Doctrine and its migrations:

terminal
$ composer require symfony/orm-pack

Set DATABASE_URL in your .env file. Then enable a source, an output and the client IP:

config/packages/symfonycorp_audit_log.yaml
symfonycorp_audit_log:
    sources:
        doctrine_orm: true
    outputs:
        dbal: true
    context_providers:
        request: true   # the client IP, truncated

To also record the logged-in user, see User, IP and request ID.

Add #[Auditable] to an entity:

src/Entity/Book.php
namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use SymfonyCorp\AuditLog\Attribute\Auditable;

#[ORM\Entity]
#[Auditable]
class Book
{
    #[ORM\Id, ORM\GeneratedValue, ORM\Column]
    public ?int $id = null;

    #[ORM\Column]
    public string $title = '';
}

Create the tables. The migration creates the book table and the audit_log table:

terminal
$ bin/console doctrine:migrations:diff
$ bin/console doctrine:migrations:migrate

Without Doctrine migrations, run bin/console audit-log:setup to create the audit_log table.

Create a Book, for example in a controller:

src/Controller/BookController.php
$book = new Book();
$book->title = 'Dune';
$entityManager->persist($book);
$entityManager->flush();

Read the entries:

terminal
$ bin/console audit-log:list
 -------------------------------------- -------------- -------- ---------------------------------- ---------------------
  Id                                     Source         Action   Message                            Timestamp
 -------------------------------------- -------------- -------- ---------------------------------- ---------------------
  01a158b2-0deb-7198-9b1b-8a28b8380020   doctrine_orm   INSERT   Entity "App\Entity\Book" created   2026-10-20 09:43:46
 -------------------------------------- -------------- -------- ---------------------------------- ---------------------

No entry? - by default, a failed write is only logged. In development, set silent_failures: false to see the error. See Outputs.

Next steps

Enable more sources, choose your outputs, and see all the options in Configuration.