PHPackages                             nti/audit-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. nti/audit-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

nti/audit-bundle
================

Audit bundle for symfony3 and doctrine orm, logs any database change

v3.0.2(1y ago)12.7k2MITPHPPHP &gt;=5.4.0

Since Aug 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ntidev/DataDogAuditBundle)[ Packagist](https://packagist.org/packages/nti/audit-bundle)[ RSS](/packages/nti-audit-bundle/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (8)Dependencies (12)Versions (35)Used By (0)

Audit bundle
============

[](#audit-bundle)

This bundle creates an audit log for all doctrine ORM database related changes:

- inserts ion changes, association and dissociation actions.
- if there is an user and updates including their diffs and relation field diffs.
- many to many relatin token storage, it will link him to the log.
- the audit entries are inserted within the same transaction during **flush**, if something fails the state remains clean.

Basically you can track any change from these log entries if they were managed through standard **ORM** operations.

**NOTE:** audit cannot track DQL or direct SQL updates or delete statement executions.

Pre-Install
-----------

[](#pre-install)

To continue using **Query Loggers** methods within the audit log bundle, Symfony versions up to 6.x require the installation of **firehed/dbal-logger v1.0.1**. Make sure to have this installed before proceeding to the next step.

Install
-------

[](#install)

First, install it with composer:

```
composer require nti/audit-bundle

```

Then, add it in your **AppKernel** bundles.

```
// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        ...
        new DataDog\AuditBundle\DataDogAuditBundle(),
        ...
    );
    ...
}

```

Using Query:

```
//SQL
CREATE TABLE audit_logs (id INT AUTO_INCREMENT NOT NULL, source_id INT NOT NULL, target_id INT DEFAULT NULL, blame_id INT DEFAULT NULL, action VARCHAR(12) NOT NULL, tbl VARCHAR(128) NOT NULL, diff LONGTEXT DEFAULT NULL COMMENT'(DC2Type:json_array)', logged_at DATETIME NOT NULL, UNIQUE INDEX UNIQ_D62F2858953C1C61 (source_id), UNIQUE INDEX UNIQ_D62F2858158E0B66 (target_id), UNIQUE INDEX UNIQ_D62F28588C082A2E (blame_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE UTF8_unicode_ci ENGINE = InnoDB;
CREATE TABLE audit_associations (id INT AUTO_INCREMENT NOT NULL, typ VARCHAR(128) NOT NULL, tbl VARCHAR(128) DEFAULT NULL, label VARCHAR(255) DEFAULT NULL, fk VARCHAR(255) NOT NULL, class VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE UTF8_unicode_ci ENGINE = InnoDB;
CREATE TABLE audit_request (id INT AUTO_INCREMENT NOT NULL, method VARCHAR(255) DEFAULT NULL, controller VARCHAR(255) DEFAULT NULL, route VARCHAR(255) DEFAULT NULL, route_params LONGTEXT DEFAULT NULL, ip VARCHAR(255) DEFAULT NULL, user_name VARCHAR(255) DEFAULT NULL,portal VARCHAR(255) DEFAULT NULL, query_data LONGTEXT DEFAULT NULL, data LONGTEXT DEFAULT NULL, created_on DATETIME DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE UTF8_unicode_ci ENGINE = InnoDB;     ALTER TABLE audit_logs ADD CONSTRAINT FK_D62F2858953C1C61 FOREIGN KEY (source_id) REFERENCES audit_associations (id);
ALTER TABLE audit_logs ADD CONSTRAINT FK_D62F2858158E0B66 FOREIGN KEY (target_id) REFERENCES audit_associations (id);
ALTER TABLE audit_logs ADD CONSTRAINT FK_D62F28588C082A2E FOREIGN KEY (blame_id) REFERENCES audit_associations(id);
ALTER TABLE audit_associations ADD created_on DATETIME NOT NULL;

```

Using Doctrine Schema:

```
// Doctrine
php bin/console doctrine:schema:update -f

```

### Config

[](#config)

Enable the audit request in the project:

```
// app/config.yml
# DataDog
data_dog_audit:
    audit_request:
        enabled: true

```

If you will use a custom database connection use following config:

```
// app/config.yml
# DataDog
data_dog_audit:
    database:
        connection_name: nti_logs
    audit_request:
        enabled: true

```

See [How to Work with multiple Entity Managers and Connections](https://symfony.com/doc/3.4/doctrine/multiple_entity_managers.html "https://symfony.com/doc/3.4/doctrine/multiple_entity_managers.html")

### Annotations

[](#annotations)

Annotations has to use in the controller, add Annotations NTIAudit in the class:

```
//src/Bundle/Controller/Controller.php
use DataDog\AuditBundle\Annotations\NTIAudit;

/**
* Class Controller
* @package AppBundle\Controller
* @NTIAudit()
* @Route("/controller")
*/
class Controller extends Controller {
    //TODO CODE HERE
}

```

### Unaudited Entities

[](#unaudited-entities)

Sometimes, you might not want to create audit log entries for particular entities. You can achieve this by listing those entities under the `unaudited_entities` configuration key in your `config.yml`, for example:

```
data_dog_audit:
    unaudited_entities:
        - AppBundle\Entity\NoAuditForThis

```

### Specify Audited Entities

[](#specify-audited-entities)

Sometimes, it is also possible, that you want to create audit log entries only for particular entities. You can achieve it quite similar to unaudited entities. You can list them under the `audited_entities` configuration key in your `config.yml`, for example:

```
data_dog_audit:
    audited_entities:
        - AppBundle\Entity\AuditForThis

```

You can specify either audited or unaudited entities. If both are specified, only audited entities would be taken into account.

### Command

[](#command)

For delete audit data:

```
php bin/console nti:audit:delete {qtyDays}

```

License
-------

[](#license)

NTI

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~115 days

Recently: every ~308 days

Total

30

Last Release

577d ago

Major Versions

v0.1.21 → v1.0.02021-04-09

v1.0.0 → v2.0.02021-04-27

v2.0.3 → v3.0.02024-09-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/d33aa0220bae1b0c48f14fc349b7b3181fec7aa674da145ded4446f2b098fe47?d=identicon)[ntidev](/maintainers/ntidev)

---

Top Contributors

[![l3pp4rd](https://avatars.githubusercontent.com/u/132389?v=4)](https://github.com/l3pp4rd "l3pp4rd (31 commits)")[![angelbencosme](https://avatars.githubusercontent.com/u/6846866?v=4)](https://github.com/angelbencosme "angelbencosme (14 commits)")[![bvisonl](https://avatars.githubusercontent.com/u/4421747?v=4)](https://github.com/bvisonl "bvisonl (8 commits)")[![chancegarcia](https://avatars.githubusercontent.com/u/348263?v=4)](https://github.com/chancegarcia "chancegarcia (5 commits)")[![whernandez](https://avatars.githubusercontent.com/u/37089069?v=4)](https://github.com/whernandez "whernandez (4 commits)")[![andreasferber](https://avatars.githubusercontent.com/u/4956110?v=4)](https://github.com/andreasferber "andreasferber (3 commits)")[![marco-mdl](https://avatars.githubusercontent.com/u/33692435?v=4)](https://github.com/marco-mdl "marco-mdl (3 commits)")[![yansellrivasdiaz](https://avatars.githubusercontent.com/u/38452151?v=4)](https://github.com/yansellrivasdiaz "yansellrivasdiaz (3 commits)")[![krzysztofruszczynski](https://avatars.githubusercontent.com/u/9629651?v=4)](https://github.com/krzysztofruszczynski "krzysztofruszczynski (2 commits)")[![vytautas-k](https://avatars.githubusercontent.com/u/10547406?v=4)](https://github.com/vytautas-k "vytautas-k (2 commits)")[![mix6s](https://avatars.githubusercontent.com/u/6933381?v=4)](https://github.com/mix6s "mix6s (2 commits)")[![FVSoftwareDeveloper](https://avatars.githubusercontent.com/u/99698678?v=4)](https://github.com/FVSoftwareDeveloper "FVSoftwareDeveloper (2 commits)")[![ivanmendoza20111](https://avatars.githubusercontent.com/u/11916100?v=4)](https://github.com/ivanmendoza20111 "ivanmendoza20111 (1 commits)")[![ndench](https://avatars.githubusercontent.com/u/2062388?v=4)](https://github.com/ndench "ndench (1 commits)")[![phryneas](https://avatars.githubusercontent.com/u/4282439?v=4)](https://github.com/phryneas "phryneas (1 commits)")[![ealcantara22](https://avatars.githubusercontent.com/u/56136351?v=4)](https://github.com/ealcantara22 "ealcantara22 (1 commits)")[![Mopster](https://avatars.githubusercontent.com/u/155956?v=4)](https://github.com/Mopster "Mopster (1 commits)")[![jonathanstidwillvf](https://avatars.githubusercontent.com/u/14923116?v=4)](https://github.com/jonathanstidwillvf "jonathanstidwillvf (1 commits)")[![dtomasi](https://avatars.githubusercontent.com/u/1616726?v=4)](https://github.com/dtomasi "dtomasi (1 commits)")[![DamienHarper](https://avatars.githubusercontent.com/u/2448660?v=4)](https://github.com/DamienHarper "DamienHarper (1 commits)")

---

Tags

logbundleormdoctrineAuditsymfony3

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nti-audit-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/nti-audit-bundle/health.svg)](https://phpackages.com/packages/nti-audit-bundle)
```

###  Alternatives

[data-dog/audit-bundle

Audit bundle for symfony2 and doctrine orm, logs any database change

141901.7k1](/packages/data-dog-audit-bundle)[sonata-project/doctrine-orm-admin-bundle

Integrate Doctrine ORM into the SonataAdminBundle

46117.7M155](/packages/sonata-project-doctrine-orm-admin-bundle)[omines/datatables-bundle

Symfony DataTables Bundle with native Doctrine ORM, Elastica and MongoDB support

2851.4M6](/packages/omines-datatables-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1022.4k](/packages/rcsofttech-audit-trail-bundle)[data-dog/pager-bundle

Paginator bundle for symfony2 and doctrine orm, allows customization with filters and sorters

11103.5k7](/packages/data-dog-pager-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
