PHPackages                             noop/flushlog - 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. noop/flushlog

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

noop/flushlog
=============

03[2 PRs](https://github.com/andrewtch/noopflushlog/pulls)PHP

Since Nov 14Pushed 3y ago1 watchersCompare

[ Source](https://github.com/andrewtch/noopflushlog)[ Packagist](https://packagist.org/packages/noop/flushlog)[ RSS](/packages/noop-flushlog/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (3)Used By (0)

What's this?
============

[](#whats-this)

This is add-on to [Doctrine2](https://github.com/doctrine/orm) the implements `EntityManager::flush()` logging and history. It can serve as a replacement to both [EntityAudit](https://github.com/simplethings/EntityAuditBundle) and Atlantic18 [Loggable / Blameable](https://github.com/Atlantic18/DoctrineExtensions) extensions.

Why?
====

[](#why)

Because relations. Most of the libraries log single entity changes, but a change in `ProductTranslation` is actually a change in `Product` from application perspective. Collection updates also matter (who attached that image to this product?).

Therefore, this library logs *flushes*, consisting of many changes (insertions, removals, deletions, AND collection changes). Also, it tries to be a low-level library, that does not create new entities on each flush, manipulating DBAL directly.

How?
====

[](#how)

Basically, this library serializes `UnitOfWork` into JSON and relies on DB native functions to browse and search the logs. This seems like as the only way to log relation changes (who added tag "Cancelled" to order #216?), and provides a bit of flexibility.

It is stable? What is supported?
================================

[](#it-is-stable-what-is-supported)

*Stability*: in development. Please join!

*Database support*: MySQL 5.6+

*ORM*: 2.5+

*PHP*: 7.1+

Features
========

[](#features)

- filtering entities
- filtering entity fields (entity is tracked only if one of the fields is updated)
- collection change tracking
- "Affected entities" concept. `ProductTranslation` change affects `Product` change, event if the `Product` entity wasn't changed at all.

FAQ
===

[](#faq)

**JSON search is very slow. Can you add indexes?**

No and this is a bad approach. If your application relies on entity changes and queries the flushlog frequently, a viable approach would be to use external search system that can work with JSON - like Elasticsearch, Sphinxsearch, or Lucene.

**Can you support versioning of objects?**

Yes, I could (creating a version for each entity, linking to particular flushlog), but it will take some time. You can submit a pull request or, alternatively, sponsor the development.

And Symfony?
============

[](#and-symfony)

There is a bundle in development.

Ok, how do I install it?
========================

[](#ok-how-do-i-install-it)

1. Initialize the `FlushLogSubscriber`:

```
$subscriber = new Noop\FlushlLog\Doctrine\ORM\FlushLogSubscriber();
```

2. Set the configuration (see example below):

```
$subscriber->setConfiguration(...);
```

3. Add the subscriber to Doctrine's `EventManager`:

```
$eventManager->addEventSubscriber($subscriber);
```

4. Extend `Noop\FlushLog\Doctrine\Entity\BaseLogEntry` to update your schema accordingly (it's a `MappedSuperclass`, so your entity should be beautifully empty):

```
