Skip to main content

The #[FlareJob] attribute

Zeridion\Flare\Worker\FlareJob is a PHP 8 attribute that configures a job class. Apply it to any Job or RecurringJob implementation.

use Zeridion\Flare\Worker\FlareJob;

#[FlareJob(
name: 'SendWelcomeEmail',
queue: 'email',
maxAttempts: 5,
timeoutSeconds: 60,
)]
final class SendWelcomeEmail implements Job { /* ... */ }

Parameters

ParameterTypeDefaultDescription
namestring''The wire job type. When empty, the fully-qualified class name is used.
queuestring'default'Queue this job runs on.
maxAttemptsint3Maximum attempts before the server dead-letters the job.
timeoutSecondsint1800Per-attempt timeout. Also drives the heartbeat cadence.
cronstring''Cron expression (recurring jobs only).
timezonestring''Timezone for the cron expression (recurring jobs only).
payloadClass?stringnullHydrate the payload into this class instead of an array.

The name (wire job type)

The name is the routing key the server uses to match a job to a handler. Set it explicitly when the same job type might be enqueued from another language or service — a shared queue needs everyone to agree on one string. If you omit name, the fully-qualified class name is used, which is fine for a PHP-only fleet but won't line up with a differently-named handler elsewhere.

#[FlareJob(name: 'SendWelcomeEmail')] // explicit, cross-language safe
#[FlareJob] // wire type = App\Jobs\SendWelcomeEmail

Timeout and heartbeats

timeoutSeconds is the per-attempt deadline. The worker also uses it to set the heartbeat cadence (max(10s, timeout / 3)), and trips the job's cancellation handle when the deadline passes.

Recurring fields

cron and timezone apply only to recurring jobs. Always provide a timezone for non-UTC schedules.

See also