Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Entity Trail Bundle

Entity Trail Bundle Laravel Package

anglemx/entity-trail-bundle

View on GitHub
Deep Wiki
Context7

Listens to Doctrine lifecycle events and writes a JSON diff to a single trail_logs table whenever any tracked entity is created, updated, or soft-deleted. Every row records: which entity, which record, what changed (old → new), who did it, and when.

Frequently asked questions about Entity Trail Bundle
Can EntityTrailBundle work with Laravel applications, or is it strictly for Symfony?
EntityTrailBundle is designed for Symfony, not Laravel. While Laravel shares some Doctrine concepts, this package relies heavily on Symfony’s event system and bundle architecture, which aren’t directly compatible. For Laravel, consider alternatives like `gedmo/doctrine-extensions` or custom audit solutions using Laravel’s event listeners.
What Laravel versions or Doctrine ORM versions does this package support?
This package is built for Symfony 6.4+ and PHP 8.2+, not Laravel. Doctrine ORM compatibility depends on Symfony’s version, but Laravel’s Doctrine integration (if used) may not align perfectly. Always check the Symfony Doctrine version against your Laravel project’s Doctrine setup for potential conflicts.
How do I configure EntityTrailBundle to track specific fields or ignore sensitive data like passwords?
Use annotations like `@Trail` on entities or configure via YAML/XML to specify which fields to audit. Exclude sensitive fields by omitting them from the trail configuration or using custom logic in a `TrailListener`. The package doesn’t natively support field-level exclusion, so you may need to extend it or pre-process entity data.
Will this package slow down my application, especially in high-write environments?
Yes, audit logging adds database writes and event listener overhead. For high-write applications, benchmark performance under load. Consider batching writes or using async processing (e.g., Symfony Messenger) to mitigate latency. The package doesn’t include built-in throttling, so you may need to implement it yourself.
How do I set up the database schema for audit logs? Does it support migrations?
The package requires two tables: `entity_trail` (for entity-level changes) and `entity_trail_field` (for field-level changes). Use Doctrine migrations to create these tables. The README provides schema examples, but you’ll need to generate and run migrations manually (e.g., via `php bin/console doctrine:migrations:diff` and `php bin/console doctrine:migrations:migrate`).
Can I customize the audit log storage or use a different database for logs?
Audit logs are stored in Doctrine entities by default, so they must reside in the same database. The package doesn’t support external storage (e.g., Elasticsearch or a separate DB) out of the box. For custom storage, you’d need to extend the `TrailManager` service or override the repository logic.
How do I test that audit logs are working correctly in my Symfony application?
Test by creating or updating entities and verifying logs in the `entity_trail` tables. Use PHPUnit to assert log entries exist after specific actions. For edge cases (e.g., nested entities), mock the `TrailManager` or use a test database. The package doesn’t include built-in test utilities, so you’ll need to write custom assertions.
Is there a way to archive or purge old audit logs automatically?
The package doesn’t include built-in archiving or TTL features. You’ll need to implement this manually, such as with a cron job or Symfony command to delete logs older than a threshold. Consider adding a `soft deletable` behavior to the audit entities if you want to retain data for compliance.
What happens if I have complex entity relationships or nested entities? Will they be audited correctly?
The package audits entities and their fields, but nested entities (e.g., `@ManyToMany` or `@OneToMany`) may not be fully tracked by default. Test thoroughly with your entity structure, as the package doesn’t explicitly document support for all Doctrine relationship types. You may need to configure custom listeners for deep relationships.
Are there alternatives to EntityTrailBundle for Symfony that offer more features or better performance?
For Symfony, alternatives include `gedmo/doctrine-extensions` (which offers similar audit logging) or `stof/doctrine-extensions-bundle`. If you need more control, consider building a custom solution using Doctrine lifecycle events. Evaluate based on your needs: EntityTrailBundle is lightweight but less feature-rich than some alternatives.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle