dualmedia/savepoint-prevent-crash-bundle
doctrine-retry-bundle, suggesting use cases where idempotency + transaction safety are critical (e.g., payment processing).doctrine/dbal or doctrine/orm (via packages like laravel-doctrine/orm). The bundle’s core logic (savepoint rollback handling) is DBAL-agnostic, but Symfony-specific middleware (e.g., EventDispatcher) may need adaptation.BEGIN, SAVEPOINT, and ROLLBACK TO syntax. Laravel’s database layer supports these natively (via DB::transaction() or DB::connection()->beginTransaction()).DatabaseMigrations or PestPHP can simulate MariaDB-specific behaviors.EventDispatcher is replaced by Laravel’s service container + listeners. The bundle’s SavepointCrashListener would need a Laravel-compatible rewrite.HttpFoundation).DB::rollBack() is used outside Doctrine, the bundle’s middleware may not intercept. Requires global exception handling (e.g., App\Exceptions\Handler) to delegate to the bundle’s logic.max_execution_time.SQLSTATE[HY000]: General error) be mocked in Laravel’s test environment?Connection::beginTransaction() with custom error handling) or database-level retries (e.g., innodb_rollback_on_timeout)?| Component | Laravel Equivalent | Adaptation Required |
|---|---|---|
| Symfony Bundle | Laravel Package (Composer) | Rewrite as a Laravel service provider + listeners. |
| EventDispatcher | Laravel’s Event facade or Service Container |
Replace KernelEvents with Laravel’s Events. |
| Doctrine Middleware | Laravel Middleware or DBAL Event Listeners |
Use DBAL\ConnectionEvents::postConnect or custom middleware. |
| Configuration | config/app.php (Service Providers) |
Register listeners in AppServiceProvider. |
Phase 1: Proof of Concept
symfony/event-dispatcher → Laravel’s illuminate/events.symfony/http-foundation → Remove (not needed in Laravel).SavepointCrashListener using DBAL\ConnectionEvents.User creation with a savepoint).Phase 2: Full Integration
DB::transaction() calls:
public function handle($request, Closure $next) {
DB::connection()->getDoctrineConnection()->getEventManager()->addEventListener(
ConnectionEvents::postConnect,
new SavepointCrashListener()
);
return $next($request);
}
postConnect or postTransaction events in AppServiceProvider:
$this->app->booting(function () {
DB::connection()->getDoctrineConnection()->getEventManager()->addEventListener(
ConnectionEvents::postConnect,
new \DualMedia\DoctrineRetryBundle\Listener\SavepointCrashListener()
);
});
DB::statement() to intercept ROLLBACK TO queries (less robust).Phase 3: Validation
SQLSTATE[HY000]).doctrine/dbal:^3.0).pdo_mysql is used (not mysqlnd or other abstractions).doctrine/dbal and dualmedia/doctrine-retry-bundle (if using retries).AppServiceProvider::boot()).postConnect event).spatie/laravel-circuit-breaker) if the bundle fails to prevent crashes.dualmedia/doctrine-retry-bundle for breaking changes.APP_DEBUG=true) and log ConnectionEvents.SQLSTATE[HY000] errors.AB or k6 to measure TPS before/after integration.How can I help you explore Laravel packages today?