Note
Laravel 10 and newer versions natively support transactional job handling without the need for this package.
By using this package you easily dispatch jobs inside transactions. Cancel job on transaction rollback. Add to queue on transaction committed.
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.
-
Run
composer require therezor/laravel-transactional-jobs
in your laravel project root folder -
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;
...
}