Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Doctrine Retry Bundle Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Packagist Downloads

Doctrine Retry Bundle

A Symfony Bundle for easy retryable database transactions.

Install

Simply composer require dualmedia/doctrine-retry-bundle

Then add the bundle to your config/bundles.php file like so

return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    // other bundles ...
    DualMedia\DoctrineRetryBundle\DoctrineRetryBundle::class => ['all' => true],
];

Setup

You're free to leave the configuration as-is, otherwise all you can change is the following:

dm_doctrine_retry:
  track_nesting: '%kernel.debug%' # if true, Retrier will warn you if you nest transaction calls

Usage

use DualMedia\DoctrineRetryBundle\Retrier;
use Doctrine\ORM\EntityManagerInterface;

class Foo {
    public function __construct(
        private readonly Retrier $retrier
    ) {}
    
    public function doWork(
        int $orderId
    ): void {
        $this->retrier->execute(function (EntityManagerInterface $em) use ($orderId): void {
            // do some work which may cause deadlocks and such
            $order = $em->getRepository(SomeOrder::class)->find($orderId, \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE);
        });
    }
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui