fruitcake/laravel-doctrine). For pure Eloquent apps, this is not a direct fit and would require significant adaptation or alternative solutions (e.g., spatie/laravel-activitylog).preUpdate, prePersist, etc.), ensuring minimal intrusion into business logic. However, this also means it cannot track changes made outside the ORM (e.g., raw SQL queries).fruitcake/laravel-doctrine, integration is non-trivial and may involve rewriting event listeners or using a facade layer.EventDispatcher. A custom bridge would be needed to route Doctrine events to Laravel’s ecosystem.entity_id, changed_at, and revision for performance.Gedmo/SoftDeleteable, ensure history records are not deleted when entities are soft-deleted.EntityManager.laravel-audit-log would be easier to swap in later.SELECT *) could degrade read performance.pg_audit).spatie/laravel-activitylog or owen-it/laravel-audit-trails.spatie/laravel-activitylog (Eloquent-compatible).owen-it/laravel-audit-trails (supports both Eloquent and Doctrine).EventDispatcher. A custom bridge is needed to:
entity_id (foreign key to original table).revision (auto-incremented or UUID-based).changed_at (timestamp).action (e.g., CREATE, UPDATE, DELETE).user_id, ip_address, or other metadata.User, Order) to validate:
SchemaTool to generate history tables without downtime.@History annotations or YAML/XML config to entities gradually.// Example: Backfill history for existing users
$users = $entityManager->getRepository(User::class)->findAll();
foreach ($users as $user) {
$history = $entityManager->getRepository(History::class);
$history->recordChange($user, 'initial state', 'backfill');
}
fruitcake/laravel-doctrine is compatible.Extension class references in older versions).preUpdate, prePersist, or postRemove listeners that might interfere with history recording.flush() in a transaction.Gedmo/SoftDeleteable, configure the bundle to preserve history during soft deletes.composer require bobv/entity-history-bundle
config/packages/doctrine.yaml:
doctrine:
orm:
event_listeners:
App\Doctrine\HistoryListener: ~
// src/Doctrine/HistoryListener.php
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\LifecycleEventArgs;
class HistoryListener implements EventSubscriber
{
public function getSubs
How can I help you explore Laravel packages today?