- How do I install this package in a Laravel project using Doctrine ORM?
- Run `composer require damienharper/auditor-doctrine-provider` and ensure you have Doctrine ORM (v3.2+) and the base `auditor` package (v4.0+) installed. Configure the provider in your Doctrine setup by registering it as an event subscriber for your entities.
- Does this work with Laravel Eloquent models?
- No, this package is specifically for Doctrine ORM entities. If you're using Eloquent, consider alternatives like `spatie/laravel-activitylog` or build a custom solution with model observers.
- What Laravel versions are supported?
- This package doesn’t directly depend on Laravel—it requires Doctrine ORM (v3.2+), which works with Laravel via `laravel-doctrine/orm`. Ensure your Laravel version supports Doctrine ORM integration (typically Laravel 8+).
- How does the 1.2.0 fix for OneToMany associations improve reliability?
- The fix ensures inverse-side associations (e.g., `OrderItem → Order`) are fully audited during batch operations, preventing missed `ASSOCIATE` entries. This is critical for complex relationships where parent-child reassignments might otherwise go unlogged.
- Can I customize audit log fields like `audited_by` or `reason`?
- Yes, you can configure custom metadata via Doctrine annotations or YAML. The package supports adding fields like `audited_by` (user ID) or `reason` (change justification) to enrich audit entries.
- Will this impact performance in high-traffic applications?
- Audit logging adds database writes on entity changes. The 1.2.0 fix may slightly increase writes during batch operations. Mitigate this by using async logging (e.g., Laravel queues) or benchmarking under production-like loads.
- How do I store audit logs in a separate database or Elasticsearch?
- By default, logs use the same database as your entities. To extend storage, override the `AuditLogger` interface or configure a custom writer to forward logs to Elasticsearch or another system.
- Are there alternatives for Laravel projects not using Doctrine ORM?
- For Eloquent-based projects, use `spatie/laravel-activitylog` or build a custom solution with model events. If you’re already using Doctrine, this package is a lightweight, event-driven alternative to manual logging.
- How do I test audit logs in a CI pipeline?
- Mock Doctrine events in your tests (e.g., `prePersist`, `preUpdate`) and verify audit entries via repository queries. Use the package’s `AuditLogger` interface to assert logged changes without hitting a real database.
- What happens if I upgrade Doctrine ORM in the future?
- The package targets Doctrine ORM v3.2+, so minor upgrades are unlikely to break compatibility. Monitor the `auditor` and `auditor-doctrine-provider` changelogs for major version requirements and test thoroughly after upgrades.