PHPackages                             dyrynda/terminable-jobs - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. dyrynda/terminable-jobs

ActiveLibrary[Queues &amp; Workers](/categories/queues)

dyrynda/terminable-jobs
=======================

Allows you to make your Laravel queued jobs terminable.

30PHP

Since Mar 5Pushed 5y ago1 watchersCompare

[ Source](https://github.com/michaeldyrynda/terminable-jobs)[ Packagist](https://packagist.org/packages/dyrynda/terminable-jobs)[ RSS](/packages/dyrynda-terminable-jobs/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Terminable Jobs logo](.github/logo.png)](.github/logo.png)

Terminable jobs is a small package that allows you to halt execution of queued Laravel jobs.

Usage example
-------------

[](#usage-example)

Lets say you have a queued jobs as follows:

```
class PromotionalCampaign implements ShouldQueue
{
    use InteractsWithQueue, Queuable;

    public function __construct()
    {
        // ...
    }

    public function handle()
    {
        // ...
    }
}
```

Suppose that after queueing up thousands of jobs to email your promotional campaign to your users, you discover a typo or missing link to the promotion itself.

You may want to `queue:flush`, but if your jobs are on a shared queue, you would be flushing *all* jobs on that queue, even if they're not the ones intended, which may lead to lost processing.

Enter Terminable Jobs.

```
+ use Dyrynda\TerminableJobs\Terminable;

class PromotionalCampaign implements ShouldQueue
{
-    use InteractsWithQueue, Queuable;
+    use InteractsWithQueue, Terminable, Queuable;

     public function handle()
     {
+        $this->handleTermination();
         // ...
     }
+
+    protected function shouldTerminate(): bool
+    {
+        // Logic to determine if job should be terminated
+    }
```

In the event that `shouldTerminate()` returns `true`, the `handleTermination()` method will delete the job from your queue and throw a `JobWasTerminated` exception, which will stop the job from being processed.

In it's simplest form, you could simply define a config variable in your application - controlled via the `.env` file - to toggle this on and off.

```
// config/jobs.php
return [
    'promotional-campaign' => env('PROMOTIONAL_CAMPAIGN_ENABLED', true),
];
```

With this in place, you can update your `shouldTerminate()` method:

```
     protected function shouldTerminate(): bool
     {
+        return config('jobs.promotional-campaign') === false;
     }
```

This means that if you needed to halt the processing of your `PromotionalCampaign` job, you would then update the `PROMOTIONAL_CAMPAIGN_ENABLED` environment variable to `false` and restart your queue workers. Any pending jobs would then terminate early, throwing the `JobWasTerminated` exception.

To avoid extraneous reporting of exceptions to your log or bug tracking software, you may wish to add the `JobWasTerminated` class to your list of ignored exceptions:

```
// app/Exceptions/Handler.php
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
+ use Dyrynda\TerminableJobs\Exceptions\JobWasTerminated;

class Handler extends ExceptionHandler
{
     protected $dontReport = [
+        JobWasTerminated::class,
     ];
```

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

[](#installation)

`composer require dyrynda/terminal-jobs`

Once installed, you may use the `Terminable` trait in your job classes and implement the `shouldTerminate(): bool` method on your job class.

Support
-------

[](#support)

If you are having general issues with this package, feel free to contact me on [Twitter](https://twitter.com/michaeldyrynda).

If you believe you have found an issue, please report it using the [GitHub issue tracker](https://github.com/michaeldyrynda/terminable-jobs/issues), or better yet, fork the repository and submit a pull request.

If you're using this package, I'd love to hear your thoughts. Thanks!

Treeware
--------

[](#treeware)

You're free to use this package, but if it makes it to your production environment you are required to buy the world a tree.

It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to plant trees. If you support this package and contribute to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

You can buy trees [here](https://plant.treeware.earth/michaeldyrynda/terminable-jobs).

Read more about Treeware at [treeware.earth](https://treeware.earth)

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/558441?v=4)[Michael Dyrynda](/maintainers/michaeldyrynda)[@michaeldyrynda](https://github.com/michaeldyrynda)

---

Top Contributors

[![michaeldyrynda](https://avatars.githubusercontent.com/u/558441?v=4)](https://github.com/michaeldyrynda "michaeldyrynda (1 commits)")

### Embed Badge

![Health badge](/badges/dyrynda-terminable-jobs/health.svg)

```
[![Health](https://phpackages.com/badges/dyrynda-terminable-jobs/health.svg)](https://phpackages.com/packages/dyrynda-terminable-jobs)
```

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.6M31](/packages/league-geotools)[illuminate/bus

The Illuminate Bus package.

6046.3M542](/packages/illuminate-bus)[uecode/qpush-bundle

Asynchronous processing for Symfony using Push Queues

1672.5M2](/packages/uecode-qpush-bundle)[belvg/module-sqs

N/A

1544.6k](/packages/belvg-module-sqs)[bsidev/bitrix-queue

Queues for Bitrix CMS

232.8k](/packages/bsidev-bitrix-queue)[lelivrescolaire/sqs-bundle

Communicate with an SQS queue from inside your symfony 2 application.

109.6k](/packages/lelivrescolaire-sqs-bundle)

PHPackages © 2026

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