lenorix/laravel-job-status

Job ULID, status and result made easy and simple

v0.1.0 2025-04-28 10:00 UTC

This package is auto-updated.

Last update: 2025-04-28 10:18:51 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Job ULID, status and result made easy and simple.

Support us

Support this work in GitHub or get in contact.

Installation

You can install the package via composer:

composer require lenorix/laravel-job-status

It requires Laravel 11 or higher, and is tested on 11.37 as lowest version supported.

You can publish and run the migrations with:

php artisan vendor:publish --tag="laravel-job-status-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="laravel-job-status-config"

This is the contents of the published config file:

return [
];

Usage

In your job class:

use Lenorix\LaravelJobStatus\Traits\Trackable;

class YourJob implements ShouldQueue
{
    use Queueable;
    use Trackable; // Add this trait to your job.

    public function handle()
    {
        // Optional, only if you want to get result with the tracker.
        // It must serialize to JSON well.
        $this->setResult(...);
    }
}

And when you dispatch the job:

$tracker = YourJob::dispatch(...)
        ->afterResponse()
        ...
        /// Get tracker to have a way to know when it's done.
        ->getJob()
        ->tracker();

$tracker->id; // Get the tracker ULID to check it in another request.

if ($tracker->isSuccessful()) {
    ...
}
if ($tracker->isFailed()) {
    ...
}
if ($tracker->isPending()) {
    ...
}

$tracker->result; // Get the result of the job, or null if not set.

If you have the ULID:

use Lenorix\LaravelJobStatus\Facades\JobStatus;

$tracker = JobStatus::of($ulid);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.