prePersist, preUpdate, preRemove, etc.), ensuring minimal performance overhead by only processing relevant operations.@Audited) to mark entities, which is intuitive and non-intrusive.audit_entry, audit_entry_metadata, etc.), which must be accounted for in migrations and CI/CD pipelines.EventDispatcher, SecurityBundle). Porting to Laravel would require:
SecurityContext) via Laravel’s Auth facade.alli-govender/auditor-bundle) lacks stars/community adoption, raising questions about long-term support.Auth or a custom service?spatie/laravel-activitylog been considered? Why choose this bundle?prePersist, preUpdate, preRemove, and postFlush events.@Audited entities.audit_entry tables.SecurityContext.EventDispatcher with Laravel’s service providers and listeners.// app/Providers/EventServiceProvider.php
public function boot()
{
\Event::listen('eloquent.saving', function ($model) {
if (method_exists($model, 'isAuditable') && $model->isAuditable()) {
// Custom audit logic (e.g., log to DB or queue)
}
});
}
damienharper/auditor) and adapt it to Laravel’s DI container.SecurityContext) with Laravel equivalents.\Event::listen('eloquent.deleted', function ($model) {
AuditLog::dispatch($model)->delay(now()->addSeconds(5));
});
| Step | Symfony Path | Laravel Path |
|---|---|---|
| 1. Dependency Installation | composer require alli-govender/auditor-bundle |
composer require damienharper/auditor (core library) |
| 2. Configuration | Configure config/packages/auditor.yaml |
Publish config via service provider |
| 3. Entity Annotation | Add @Audited to Doctrine entities |
Use traits or custom annotations (e.g., #[Auditable]) |
| 4. Event Listeners | Bundle provides listeners | Implement custom listeners or adapt bundle logic |
| 5. Database Schema | Bundle creates audit_entry tables |
Manually create tables or use migrations |
| 6. User Context | Uses SecurityContext |
Use Laravel’s Auth::user() or custom resolver |
| 7. Testing | Symfony test utilities | Laravel’s testing helpers (e.g., assertDatabaseHas) |
eloquent.saving vs. Symfony’s prePersist).doctrine/annotations.doctrine/annotations or native PHP 8 attributes (#[Attribute]).autowiring and services.yaml.SecurityBundle provides SecurityContext.Auth facade or custom guard.Auth::id() or custom logic).@Audited usage (or equivalent).How can I help you explore Laravel packages today?