Skip to main content
Lyger’s job system allows you to defer time-consuming tasks to background workers, keeping your application responsive. Perfect for sending emails, processing images, generating reports, and other heavy operations.

Creating Jobs

Jobs extend the base Job class and define a handle() method:
The $tries property defines how many times to retry on failure. The $backoff property sets the delay (in seconds) between retries.

Dispatching Jobs

Immediate Dispatch

Queue a job for background processing:

Delayed Dispatch

Queue a job to run after a delay:

Using Dispatchable Trait

Make jobs easier to dispatch with the Dispatchable trait:

Queue Workers

Process queued jobs with a worker:

Start Worker

Worker Script

Create a worker script:
Run the worker:
Workers run indefinitely. Use a process manager like Supervisor to ensure they restart if they crash.

Job Properties

Configure job behavior with properties:

Property Reference

Multiple Queues

Organize jobs into different queues:

Queue Sizes

Check queue status:

Job Chaining

Execute jobs in sequence:
Chained jobs run sequentially. If one fails, the chain stops.

Task Scheduling

Schedule recurring tasks with the Scheduler:

Basic Scheduling

Cron-Style Scheduling

Use cron expressions for precise scheduling:

Schedule Runner

Run scheduled tasks:

Real-World Examples

Email Notification System

Image Processing

Report Generation

Failed Jobs

Handle and inspect failed jobs:

Supervisor Configuration

Keep workers running in production:

Performance Tips

Process multiple items in one job:
Use separate workers for priority queues:
Prevent memory leaks by limiting jobs per worker:

Next Steps

Cache

High-performance caching

Events

Event system and broadcasting