Skip to content

Run Laravel job inside transaction (after transaction is committed, or cancel if rolled back)

License

Notifications You must be signed in to change notification settings

therezor/laravel-transactional-jobs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel transactional jobs

Note

Laravel 10 and newer versions natively support transactional job handling without the need for this package.

Problem:

Solution:

By using this package you easily dispatch jobs inside transactions. Cancel job on transaction rollback. Add to queue on transaction committed.

Installation

This package requires PHP 7.1 and Laravel 5.8 or higher. If you are on a PHP version below 7.1 or a Laravel version below 5.8 just use an older version of this package.

  1. Run composer require therezor/laravel-transactional-jobs in your laravel project root folder

  2. Implement TheRezor\TransactionalJobs\Contracts\RunAfterTransaction to jobs that run in the middle of database transactions

<?php

use TheRezor\TransactionalJobs\Contracts\RunAfterTransaction;

class MySuperJob implements ShouldQueue, RunAfterTransaction
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    
    ...
}

About

Run Laravel job inside transaction (after transaction is committed, or cancel if rolled back)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages