Search by

idlab / loggable

Evlyn

Allows you to log updates occurring on entities

Package info

github.com/idlab-geneve/loggable-bundle

Type:symfony-bundle

pkg:composer/idlab/loggable

Statistics

Installs: 498

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

2.0.0 2026-09-15 13:45 UTC

This package is not auto-updated.

Last update: 2026-09-17 08:35:28 UTC


README

This bundle supports Symfony 6.4, 7.x, and 8.x on PHP 8.2 or newer. Symfony 8 requires PHP 8.4 or newer.

Configuration in doctrine.yaml

To set under the wished connection configuration :

doctrine:
  orm:
    entity_manager:
      default:
        idlab_loggable:
          prefix: Idlab\Loggable\Entity
          dir: "%kernel.project_dir%/vendor/idlab/loggable/src/Entity"

NOTE: If you are using the short syntax for the ORM configuration, the mappings key is directly under orm:

Package file configuration

You can add a config file name "idlab_loggable.yaml" in config/packages in you Symfony project :

idlab_loggable:
  enabled: true
  logs_target_connection_name: 'default'
  table_prefix: 'example_table_prefix_'
  disallowed_namespaces: [
    'App\Entity\IgnoredByNamespace'
  ],
  disallowed_classes: [
    'App\Entity\IgnoredByClass'
  ]

Add IdlabLoggable attribute

Import : 
use Idlab\Loggable\Mapping\Attributes\IdlabLoggable;

#[IdlabLoggable]
public ?string $value = null;

To log all Doctrine-mapped properties of an entity, put the attribute on the class. Exclude individual properties with IdlabLoggableExclude:

use Idlab\Loggable\Mapping\Attributes\IdlabLoggable;
use Idlab\Loggable\Mapping\Attributes\IdlabLoggableExclude;

#[IdlabLoggable]
class Order
{
    private string $status;

    #[IdlabLoggableExclude]
    private string $internalNote;
}

Property-level IdlabLoggable remains supported for selective logging. A property exclusion takes precedence over both class-level and property-level logging attributes. Backed enums are logged using their backing value; pure enums are logged using their case name.

Deprecated accessors

Version 2 renamed the log entry properties and database columns from createdAt/createdBy to loggedAt/username. The old accessors remain available for compatibility but are deprecated:

Deprecated Use instead
getCreatedAt() getLoggedAt()
getCreatedBy() getUsername()

Update application code to use the replacement methods. The deprecated accessors may be removed in a future major version.

EntityLogEntry is immutable after construction. Version 2 removes all setters from the entity so persisted audit records cannot be changed through the entity API. Doctrine can hydrate the private fields without setters.