PHPackages                             sammyjo20/laravel-haystack - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. sammyjo20/laravel-haystack

AbandonedArchivedLibrary[Database &amp; ORM](/categories/database)

sammyjo20/laravel-haystack
==========================

Supercharged job chains for Laravel

v2.2.0(2y ago)605217.5k↑94.6%27MITPHPPHP ^8.1

Since Aug 1Pushed 2y ago9 watchersCompare

[ Source](https://github.com/Sammyjo20/laravel-haystack)[ Packagist](https://packagist.org/packages/sammyjo20/laravel-haystack)[ Docs](https://github.com/sammyjo20/laravel-haystack)[ RSS](/packages/sammyjo20-laravel-haystack/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (33)Used By (0)

> ### Notice 14/05/2024
>
> [](#notice-14052024)
>
> I am no longer going to be accepting new features for Laravel Haystack. I intend to still ensure security fixes are made, but I feel that the project is now complete. Additionally, I feel that Laravel's job batches and chains in Laravel 10+ are a lot more powerful and you may not need Laravel Haystack in 2024.

[![](https://user-images.githubusercontent.com/29132017/181642184-e95e6214-2ff0-4a32-985e-938432b7b3f5.jpeg)](https://user-images.githubusercontent.com/29132017/181642184-e95e6214-2ff0-4a32-985e-938432b7b3f5.jpeg)Laravel Haystack
================

[](#laravel-haystack)

⚡️ Supercharged job chains for Laravel

[![Build Status](https://github.com/sammyjo20/laravel-haystack/actions/workflows/tests.yml/badge.svg)](https://github.com/sammyjo20/laravel-haystack/actions/workflows/tests.yml/badge.svg)

[Click here to read the documentation](https://docs.laravel-haystack.dev)

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();
```

#### But doesn't Laravel already have job chains?

[](#but-doesnt-laravel-already-have-job-chains)

That's right! Laravel does have job chains but they have some disadvantages that you might want to think about.

- They consume quite a lot of memory/data since the chain is stored inside the job. This is especially true if you are storing thousands of jobs.
- They are volatile, meaning if you lose one job in the chain - you lose the whole chain.
- They do not provide the `then`, `catch`, `finally` callable methods that batched jobs do.
- Long delays with memory-based or SQS queue is not possible as you could lose the jobs due to expiry or if the server shuts down.
- You can't share data between jobs as there is no "state" across the chain

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.

#### Laravel Haystack Features

[](#laravel-haystack-features)

- Low memory consumption as one job is processed at a time and the chain is stored in the database
- You can delay/release jobs for as long as you want since it will use the scheduler to restart a chain. Even if your queue driver is SQS!
- It provides callback methods like `then`, `catch` and `finally`.
- Global middleware that can be applied to every single job in the chain
- You can store models and data that are shared with every job in the chain.
- You can prepare a Haystack and dispatch it at a later time

#### Use Cases

[](#use-cases)

- If you need to make hundreds or thousands of API calls in a row, can be combined with Spatie's Job Rate Limiter to keep track of delays and pause jobs when a rate limit is hit.
- If you need to queue thousands of jobs in a chain at a time.
- If you need to batch import rows of data - each row can be a haystack job (bale) and processed one at a time. While keeping important job information stored in the database.
- If you need "release" times longer than 15 minutes if you are using Amazon SQS

Installation
------------

[](#installation)

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
```

Documentation
-------------

[](#documentation)

[Click here to read the documentation](https://docs.laravel-haystack.dev)

Support Haystack's Development
------------------------------

[](#support-haystacks-development)

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!

[![Buy Me a Coffee at ko-fi.com](https://camo.githubusercontent.com/7f803b4c3a634f4d451c4310d00c2520aae1f15ef910420a0f27890e3c4787dd/68747470733a2f2f617a3734333730322e766f2e6d7365636e642e6e65742f63646e2f6b6f6669332e706e673f763d30)](https://ko-fi.com/sammyjo20)

Thank you for using Laravel Haystack ❤️

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity55

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 90.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~21 days

Recently: every ~109 days

Total

32

Last Release

734d ago

Major Versions

v0.12.0 → v1.0.02023-03-03

v1.0.0 → v2.0.02023-08-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/de41c8bfde9d0edb25da9fdc159283fe9442e3dc9b651ee9aa7ded8384e5629d?d=identicon)[SamCarre](/maintainers/SamCarre)

---

Top Contributors

[![Sammyjo20](https://avatars.githubusercontent.com/u/29132017?v=4)](https://github.com/Sammyjo20 "Sammyjo20 (306 commits)")[![ksimenic](https://avatars.githubusercontent.com/u/12883124?v=4)](https://github.com/ksimenic "ksimenic (15 commits)")[![viicslen](https://avatars.githubusercontent.com/u/39545521?v=4)](https://github.com/viicslen "viicslen (6 commits)")[![faisuc](https://avatars.githubusercontent.com/u/7190009?v=4)](https://github.com/faisuc "faisuc (4 commits)")[![amaelftah](https://avatars.githubusercontent.com/u/17250137?v=4)](https://github.com/amaelftah "amaelftah (3 commits)")[![gabrielchiron](https://avatars.githubusercontent.com/u/9168343?v=4)](https://github.com/gabrielchiron "gabrielchiron (1 commits)")[![cognitus](https://avatars.githubusercontent.com/u/2235718?v=4)](https://github.com/cognitus "cognitus (1 commits)")[![stevebauman](https://avatars.githubusercontent.com/u/6421846?v=4)](https://github.com/stevebauman "stevebauman (1 commits)")[![andershagbard](https://avatars.githubusercontent.com/u/9662430?v=4)](https://github.com/andershagbard "andershagbard (1 commits)")

---

Tags

chained-jobsdatabasejobslaravelphpqueuesammyjo20laravel-haystack

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/sammyjo20-laravel-haystack/health.svg)

```
[![Health](https://phpackages.com/badges/sammyjo20-laravel-haystack/health.svg)](https://phpackages.com/packages/sammyjo20-laravel-haystack)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[spatie/laravel-health

Monitor the health of a Laravel application

86910.0M83](/packages/spatie-laravel-health)[laravel/pennant

A simple, lightweight library for managing feature flags.

57711.1M53](/packages/laravel-pennant)[illuminate/queue

The Illuminate Queue package.

20331.4M1.2k](/packages/illuminate-queue)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
