lenorix / laravel-job-status
Job ULID, status and result made easy and simple
Fund package maintenance!
lenorix
Requires
- php: ^8.3||^8.4
- illuminate/contracts: ^11.37||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9||^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3||^2.0
- phpstan/phpstan-deprecation-rules: ^1.1||^2.0
- phpstan/phpstan-phpunit: ^1.3||^2.0
README
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.