benmacha/audit-bundle
Symfony bundle to audit Doctrine entity changes with rollback support. Includes a web UI and REST API to browse audit logs, flexible configuration, security integration, and optional async processing. Supports PHP 7.4–8.4 and Symfony 5.4–7.x.
config/packages/ vs. Laravel’s config/audit.php or environment variables.doctrine/orm) alongside Eloquent, adding complexity.EventDispatcher with Laravel’s Events system.AuditBundle services) into Laravel-compatible interfaces.prePersist, preUpdate), which Laravel handles via Eloquent observers/events.EntityManager rollback vs. Eloquent’s manual query rebuilding.laravel-audit-bundle) while leveraging its design patterns.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| ORM Incompatibility | Critical | Use a Doctrine bridge or rewrite for Eloquent. |
| Event System Mismatch | High | Map Symfony events to Laravel’s Events system. |
| Configuration Overhead | Medium | Abstract Symfony’s YAML config into Laravel’s config/. |
| Performance Impact | Medium | Disable async processing or optimize batching. |
| Security Gaps | High | Reimplement role-based access control (RBAC) for Laravel’s gate/middleware. |
| Database Schema | Medium | Adapt Doctrine migrations for Laravel’s schema builder. |
owen-it/simple-audit, spatie/laravel-activitylog, or laravel-audit-log may offer lower-risk solutions.AuditService) via a custom facade that bridges Symfony’s EventDispatcher to Laravel’s Events.// Laravel Service Provider
public function register()
{
$this->app->singleton(AuditService::class, function ($app) {
$dispatcher = new LaravelEventDispatcher(); // Custom bridge
return new BenMacha\AuditBundle\Service\AuditService($dispatcher);
});
}
config/.#[Auditable] attributes to Laravel’s observers or traits.// Laravel Observer (replaces Symfony’s entity listeners)
class UserObserver
{
public function saving(User $user)
{
if ($user->isDirty('email')) {
AuditLog::create([
'entity_id' => $user->id,
'changes' => ['email' => [$user->getOriginal('email'), $user->email]],
'user_id' => auth()->id(),
]);
}
}
}
User, Order).EventDispatcher with a Laravel-compatible bridge.| Component | Laravel Compatibility | Notes |
|---|---|---|
| Entity Auditing | Medium | Requires Eloquent observers or custom traits. |
| Rollback Logic | Low | Laravel lacks native rollback; needs manual query rebuilding. |
| Web Interface | Low | Twig → Blade migration required; routing must be rewritten. |
| REST API | Low | Symfony’s API platform → Laravel’s routes + controllers. |
| Security (RBAC) | Medium | Replace Symfony’s voters with Laravel’s Gate or middleware. |
| Async Processing | Medium | Use Laravel’s queues (e.g., Horizon) instead of Symfony’s Messenger. |
audit_logs).EventDispatcher, Security). These must be mocked or replaced, increasing maintenance burden.How can I help you explore Laravel packages today?