1.1.0
Laravel Queue Laravel custom queue system.
Installation
- Use composer:
composer require m-alsafadi/laravel-queue
- Add to
.env
file:
LARAVEL_QUEUE_ENABLED=true
LARAVEL_QUEUE_DISK=local
LARAVEL_QUEUE_SINGLE_PROC=true
LARAVEL_QUEUE_CACHE=false
LARAVEL_QUEUE_LOG_CHANNEL=stack
- Add trait to your model (optional):
use \MAlsafadi\LaravelQueue\Traits\TLaravelQueueModel;
- Create job:
php artisan laravel:queue:job UserJob
- Modify
handle
method in your job at\App\Jobs\UserJob
- Start the worker:
- Via artisan command:
php artisan larave:queue:start
- Via file:
php laravel-queue
Publish config:
php artisan vendor:publish --provider=MAlsafadi\\LaravelQueue\\Providers\\LaravelQueueProvider
How to add job to queue:
- Via your job:
\App\Jobs\UserJob::addJob($model, $valid_at, $arguments, $name);
- Via your model:
\App\Models\User::find(1)->addJob(\App\Jobs\UserJob::class, $valid_at, $arguments, $name);
- Via Laravel Queue:
LaravelQueue::addJob($model, \App\Jobs\UserJob::class, $valid_at, $arguments, $name);
Info: Attribute
$name
is optional.
Commands:
- Laravel Queue Helper:
php artisan laravel:queue
- Create New Laravel Queue Job:
php artisan laravel:queue:job
- Start Laravel Queue Worker:
php artisan laravel:queue:start
License
The Laravel framework is open-sourced software licensed under the MIT license.
The Laravel Queue is open-sourced software licensed under the MIT license.