Stars: 560
Forks: 16
Pull Requests: 38
Issues: 9
Watchers: 9
Last Updated: 2023-08-22 13:21:45
⚡️ Supercharged job chains for Laravel
License: MIT License
Languages: PHP
Laravel Haystack provides supercharged job chains for Laravel. It comes with powerful features like delaying jobs for as long as you like, applying middleware to every job, sharing data and models between jobs and even chunking jobs. Laravel Haystack supports every queue connection/worker out of the box. (Database, Redis/Horizon, SQS). It's great if you need to queue thousands of jobs in a chain or if you are looking for features that the original Bus chain doesn't provide.
$haystack = Haystack::build()
->addJob(new RecordPodcast)
->addJob(new ProcessPodcast)
->addJob(new PublishPodcast)
->then(function () {
// Haystack completed
})
->catch(function () {
// Haystack failed
})
->finally(function () {
// Always run either on success or fail.
})
->withMiddleware([
// Middleware for every job
])
->withDelay(60)
->withModel($user)
->dispatch();
That's right! Laravel does have job chains but they have some disadvantages that you might want to think about.
then
, catch
, finally
callable methods that batched jobs do.Laravel Haystack aims to solve this by storing the job chain in the database and queuing one job at a time. When the job is completed, Laravel Haystack listens out for the "job completed" event and queues the next job in the chain from the database.
then
, catch
and finally
.You can install the package with Composer. Laravel Haystack Requires Laravel 8+ and PHP 8.1
composer require sammyjo20/laravel-haystack
Next, just run the installation command!
php artisan haystack:install
Click here to read the documentation
While I never expect anything, if you would like to support my work, you can donate to my Ko-Fi page by simply buying me a coffee or two!
Thank you for using Laravel Haystack ❤️