A guide to configuring auditor-bundle.
Depending on the Symfony version your application relies, configuration is located in the following file:
You can configure the timezone the audit
created_at is generated in. This by default is
dh_auditor: timezone: 'Europe/London'
auditor-bundle audits every entity declared auditable.
It is however possible to disable audits by default. In this case, nothing is audited until auditing is enabled at runtime.
dh_auditor: enabled: false
You can also enable or disable the auditing of entities per entity and at runtime if you use the built-in Doctrine provider.
A user provider is a service which goal is to return information about current user.
auditor then invokes the user provider any time it receives an audit event.
dh_auditor: # Invokable service (callable) that provides user information user_provider: ~
A security provider is a service which goal is to return security information such as current client IP, etc.
auditor then invokes the security provider any time it receives an audit event.
dh_auditor: # Invokable service (callable) that provides security information (IP, firewall name, etc) security_provider: ~
A role checker is a service which goal is to return a
boolean indicating whether permission to access
an entity's audit logs is granted for the current user.
dh_auditor: # Invokable service (callable) that checks roles roles_checker: ~
This lets you disable audit logging for an entity by default and only enable auditing when needed for example. Per entity enabling/disabling is done in the configuration file.
dh_auditor: enabled: true # auditing is globally enabled providers: doctrine: entities: App\Entity\MyEntity1: enabled: false # auditing of this entity is disabled App\Entity\MyEntity2: ~ # auditing of this entity is enabled
In the above example, an audit table will be created for
but audit entries will only be saved when auditing is explicitly enabled at runtime.
auditor-bundle provides an audit viewer letting you review the full history of any audited entity.
This viewer is disabled by default but can easily be enabled in the configuration file as shown below and can be accessed at
dh_auditor: providers: doctrine: viewer: true
If you're using flex, you are done, routes are automatically added to your application's
routing configuration (see
Otherwise, you have to manually add the following routes to the routing configuration
of your application (
dh_auditor: resource: "@DHAuditorBundle/Controller/" type: auditor
This bundle supports all of Doctrine inheritance types:
Configuring the root table to be audited does not suffice to get all child tables audited in a single table inheritance context. You have to configure every child table that needs to be audited as well.