Skip to content

Conversation

@techmahedy
Copy link
Member

This PR introduces a new PHP attribute, #[Queueable], which allows developers to explicitly mark a Job class as queueable and define its queue-related configuration directly on the class.

Before this change, all jobs extending Job were automatically treated as queueable. With this update, job classes are instant callable by default unless they are decorated with #[Queueable].

In addition, four new static methods have been added to give developers fine-grained control over how a job is dispatched.

New Attribute: #[Queueable]

// Not queued — runs immediately
class SendEmailJob extends Job
{
}

// Queued — uses Queueable attribute configuration

// Queued — uses Queueable attribute configuration
#[Queueable]
class SendEmailJob extends Job
{
}

User can add custom options also as like below

#[Queueable(tries: 3, retryAfter: 60, delayFor: 300, onQueue: 'default')]

New Dispatching Methods

Four new job dispatching methods give developers explicit control over how and when a job is executed:

$jobId = SendEmailJob::dispatchWith($user);

Dispatches the job.

  1. If the job has #[Queueable], it is queued.
  2. If not, it runs synchronously.

Forces the job to run synchronously, even if #[Queueable] is present.

SendEmailJob::queueAsSync($user);

Forces the job to be queued on a specific queue, regardless of class attributes.

$jobId = SendEmailJob::queueOn('high-priority', $user);

Queues the job with a delay (in seconds).

$jobId = SendEmailJob::queueAfter(300, $user);

This PR makes job queueing explicit, configurable, and developer-friendly, while introducing a robust attribute-driven API for queue behavior.

@techmahedy techmahedy merged commit 480bebe into doppar:1.x Nov 15, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant