dualmedia/doctrine-retry-bundle
Symfony bundle that wraps Doctrine transactions with automatic retries for deadlocks and transient DB errors. Configure optional nesting tracking, then call Retrier->execute() with a closure receiving the EntityManager to safely run retryable work.
doctrine/orm or laravel-doctrine) allows for partial adoption of its core retry logic. The Retrier class can be decoupled from Symfony’s DI container and adapted for Laravel’s service container.doctrine/orm or laravel-doctrine).Events or a custom event system).EntityManager transaction handling.TransactionStartEvent can be adapted for Laravel’s dispatch() mechanism.autoconfigure must be replaced with Laravel’s bind() or app()->make().config() or environment variables.EventDispatcherInterface → Laravel’s Illuminate\Events\Dispatcher.| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Symfony Lock-in | Bundle assumes Symfony’s DI/Events. | Decouple Retrier and EventDispatcher via interfaces; use Laravel’s equivalents. |
| Doctrine Version | Last release (2026) may not align with Laravel’s Doctrine version. | Pin doctrine/orm to a compatible version (e.g., ^2.14). |
| Retry Logic Transparency | No explicit backoff strategy documented. | Audit source code or extend Retrier to expose/configurable backoff. |
| Nested Transactions | track_nesting config may not translate cleanly to Laravel. |
Implement a custom TransactionNestingDetector or disable nesting checks. |
| Testing Overhead | Requires mocking Symfony services for Laravel integration. | Use Laravel’s Mockery or Pest for unit tests; test retry behavior in isolation. |
LockException, DeadlockException, or all DoctrineException?)Retrier be instantiated without Symfony’s ContainerInterface?TransactionStartEvent) integrate with Laravel’s dispatch()?laravel-doctrine/orm or standalone doctrine/orm).Phase 1: Dependency Extraction
Retrier class and core logic.EventDispatcherInterface → Illuminate\Contracts\Events\Dispatcher.ContainerInterface → Laravel’s Illuminate\Container\Container.config('doctrine_retry').Phase 2: Laravel Service Integration
Retrier in Laravel’s container:
$app->bind(Retrier::class, function ($app) {
return new Retrier(
$app->make(EntityManagerInterface::class),
$app->make('events') // Laravel's event dispatcher
);
});
facade(Retrier::class, RetrierFacade::class);
Phase 3: Event System Adaptation
TransactionStartEvent with a Laravel event:
class TransactionStarted implements ShouldQueue
{
public function handle() { /* ... */ }
}
Phase 4: Configuration
dm_doctrine_retry settings to config/doctrine-retry.php:
return [
'track_nesting' => app()->isLocal(),
];
| Component | Laravel Equivalent | Compatibility Notes |
|---|---|---|
| Symfony Bundle | Standalone service class | Extract core logic; avoid bundle-specific features. |
| EventDispatcher | Illuminate\Events\Dispatcher |
Use Laravel’s dispatch() or event() helpers. |
| YAML Config | config() or .env |
Convert to Laravel’s config system. |
| Autowiring | Laravel’s bind() or app()->make() |
Manually resolve dependencies if needed. |
| Doctrine ORM | doctrine/orm or laravel-doctrine/orm |
Ensure version alignment (e.g., Doctrine 2.14+). |
Retrier in one high-risk service (e.g., order processing).try-catch retry logic with the bundle.spatie/laravel-circuitbreaker).try-catch blocks.ValidationException).track_nesting is enabled).How can I help you explore Laravel packages today?