Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

troccoli's avatar

Jobs monitoring for database driver (Horizon lite if you want)

I need to implement a very simple monitoring system for our jobs, but I cannot use Horizon as we use the database driver.

The requirements a re very simple at the moment: show a list of awaiting and failed jobs, and for failed jobs show the exception and allow the user to retry it (from the UI).

My first implementation is to create Eloquent models for the jobs and failed_jobs table. I then have to write some code to json decode and unserialise (part of) the payload. To retry a job I programmatically call the queue:retry Artisan command.

This all works well enough, but I was wondering if there was a better way. I looked for composer packages that could help me but I didn't find any suitable one. I also looked into Laravel's code to see how Laravel itself deals with jobs internally. I didn't go very far though.

So, why questions are

  1. does anyone know of any package for managing jobs when using the database driver?
  2. does anyone have any suggestions or pointer on how to do this the "Laravel way"? Maybe I just need to instantiate a manager class or something, but I couldn't find anything useful.
0 likes
2 replies
LaryAI's avatar

Certainly! Here’s a detailed solution addressing your requirements and questions:


1. Packages for Managing Jobs with the database Driver

Unfortunately, there isn't a well-maintained, Horizon-like package for the database queue driver. Most queue monitoring packages (like Horizon) are tightly coupled to Redis for performance reasons. Some alternatives you might want to check (though they may not be as full-featured or actively maintained):

  • Laravel Queue Monitor
    This package can track jobs for all drivers, including database. It adds a monitor_jobs table and provides a UI, but you need to add a trait to your jobs.
  • Laravel Job Viewer
    This package provides a simple UI for viewing jobs in the jobs and failed_jobs tables. It’s basic but might fit your needs.

If these don’t fit, your custom solution is a good approach.


2. Doing It the "Laravel Way"

Laravel itself interacts with the jobs and failed_jobs tables using Eloquent and the Illuminate\Queue\DatabaseQueue class. There’s no official UI for the database driver, so your approach is reasonable and aligns with Laravel’s internals.

Key Points for Your Implementation

  • Eloquent Models:
    Create models for jobs and failed_jobs tables.

    // app/Models/Job.php
    class Job extends Model
    {
        protected $table = 'jobs';
        protected $casts = [
            'payload' => 'array',
        ];
    }
    
    // app/Models/FailedJob.php
    class FailedJob extends Model
    {
        protected $table = 'failed_jobs';
        protected $casts = [
            'payload' => 'array',
        ];
    }
    
  • Decoding Payloads:
    The payload column is JSON. You can access it as an array if you use $casts.

  • Retrying Failed Jobs:
    You can use the Artisan command programmatically:

    Artisan::call('queue:retry', [
        'id' => $failedJobId,
    ]);
    
  • Displaying Exception:
    The exception column in failed_jobs contains the stack trace.

  • Querying Awaiting and Failed Jobs:

    // Awaiting jobs
    $awaitingJobs = Job::all();
    
    // Failed jobs
    $failedJobs = FailedJob::all();
    
  • Retry from UI:
    Create a route/controller that calls the retry logic above.


Sample Controller Snippet

public function retry($id)
{
    Artisan::call('queue:retry', ['id' => $id]);
    return redirect()->back()->with('status', 'Job retried!');
}

Summary

  • There’s no official or widely-used package for database queue monitoring like Horizon.
  • Your approach (Eloquent models, decoding payloads, using queue:retry) is the "Laravel way" for the database driver.
  • You can use packages like romanzipp/laravel-queue-monitor or imliam/laravel-job-viewer for a UI, but a custom UI is also perfectly valid.
  • If you want to dig deeper, look at the Illuminate\Queue\DatabaseQueue and related classes in Laravel’s source.

If you need code for a simple UI or further help with payload decoding, let me know!

kevinbui's avatar

Regarding your first question, there are a number of popular packages/services in the community other than Horizon monitoring queued jobs.

With your second question, it's totally doable to build your own monitoring system! But we need a much more thorough understanding how the queue system work in Laravel.

Your displaying of awaiting jobs is fine. About managing failed jobs, you could resolve an instance of queue.failer :

// This will give you an instance of
// Illuminate\Queue\Failed\DatabaseUuidFailedJobProvider
// Or
// Illuminate\Queue\Failed\DatabaseFailedJobProvider
$queueFailer = app('queue.failer');

// Then we can do stuff like

// Get all failed jobs.
$queueFailer->all();

// Get a job by id.
$queueFailer->find('some_id');

Please or to participate in this conversation.