Skip to content

Execution Context

Argument Matching

Beyond execute(), executables support several optional methods: configure(), tags(), middleware(), failed(), uniqueVia(), and the named configuration methods. They all share one behavior: they receive your execute-arguments by name. Each method only needs to declare the parameters it uses. The rest are skipped.

php
class ProcessOrder
{
    use QueueableExecutable;

    public function execute(Order $order, string $priority): void
    {
        // ...
    }

    // Only declares $order. $priority is skipped, not needed here
    public function tags(Order $order): array
    {
        return ["order:{$order->id}", "customer:{$order->customer_id}"];
    }

    // $priority matched by name
    public function middleware(string $priority): array
    {
        return [new RateLimited("orders-{$priority}")];
    }
}

Parameters are matched by name and type against execute(). The included PHPStan rule flags any parameter that doesn't match, catching typos and mismatches that would otherwise only surface at runtime.

Queue Job Interaction

All standard Laravel job interaction methods are available on $this inside a queued executable: attempts(), delete(), fail(), release(), batch(), prependToChain(), appendToChain(). The underlying ExecutableJob is also available via $this->executableJob if you need direct access to the Laravel job instance (e.g., $this->executableJob->job).

php
class ProcessPayment
{
    use QueueableExecutable;

    public function execute(Payment $payment): void
    {
        if ($payment->isExpired()) {
            $this->delete();
            return;
        }

        if (!$payment->gateway->isReady()) {
            $this->release(30); // retry in 30 seconds
            return;
        }

        // process...
    }
}