PHPackages                             comstar/entity-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. comstar/entity-audit-bundle

ActiveLibrary[Database &amp; ORM](/categories/database)

comstar/entity-audit-bundle
===========================

Audit for Doctrine Entities

v0.6.0(12y ago)168New BSDPHP

Since Mar 6Pushed 9y ago1 watchersCompare

[ Source](https://github.com/comstar/EntityAudit)[ Packagist](https://packagist.org/packages/comstar/entity-audit-bundle)[ RSS](/packages/comstar-entity-audit-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (9)Used By (0)

EntityAudit Extension for Doctrine2
===================================

[](#entityaudit-extension-for-doctrine2)

This extension for Doctrine 2 is inspired by [Hibernate Envers](http://www.jboss.org/envers) and allows full versioning of entities and their associations.

```
Credits to simplethings/EntityAudit for a nice audit bundle for Symfony2 entities. This
fork was created to allow more extensability from the Event Listeners.

```

How does it work?
-----------------

[](#how-does-it-work)

There are a bunch of different approaches to auditing or versioning of database tables. This extension creates a mirroring table for each audited entitys table that is suffixed with "\_audit". Besides all the columns of the audited entity there are two additional fields:

- rev - Contains the global revision number generated from a "revisions" table.
- revtype - Contains one of 'INS', 'UPD' or 'DEL' as an information to which type of database operation caused this revision log entry.

The global revision table contains an id, timestamp, username and change comment field.

With this approach it is possible to version an application with its changes to associations at the particular points in time.

This extension hooks into the SchemaTool generation process so that it will automatically create the necessary DDL statements for your audited entities.

Installation (In Symfony2 Application)
--------------------------------------

[](#installation-in-symfony2-application)

Register Bundle in AppKernel.php

```
public function registerBundles()
{
    $bundles = array(
        //...
        new Comstar\EntityAudit\ComstarEntityAuditBundle(),
        //...
    );
    return $bundles;
}

```

Autoload

```
'Comstar\\EntityAudit' => __DIR__.'/../vendor/bundles/',

```

Load extension "comstar\_entity\_audit" and specify the audited entities (yes, that ugly for now!)

```
comstar_entity_audit:
    audited_entities:
        - MyBundle\Entity\MyEntity
        - MyBundle\Entity\MyEntity2

```

Call ./app/console doctrine:schema:update --dump-sql to see the new tables in the update schema queue.

Notice: EntityAudit currently only works with a DBAL Connection and EntityManager named "default".

Installation (Standalone)
-------------------------

[](#installation-standalone)

For standalone usage you have to pass the entity class names to be audited to the MetadataFactory instance and configure the two event listeners.

```
