{"id":"3245c3e9a97bea63","repo":"laravel/framework","slug":"to-enable-support-for-closure-jobs-please-install-3245c3","errorCode":null,"errorMessage":"To enable support for closure jobs, please install the illuminate/queue package.","messagePattern":"To enable support for closure jobs, please install the illuminate/queue package\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Console/Scheduling/Schedule.php","lineNumber":250,"sourceCode":"\n        return $event;\n    }\n\n    /**\n     * Dispatch the given job to the queue.\n     *\n     * @param  object  $job\n     * @param  string|null  $queue\n     * @param  string|null  $connection\n     * @return void\n     *\n     * @throws \\RuntimeException\n     */\n    protected function dispatchToQueue($job, $queue, $connection)\n    {\n        if ($job instanceof Closure) {\n            if (! class_exists(CallQueuedClosure::class)) {\n                throw new RuntimeException(\n                    'To enable support for closure jobs, please install the illuminate/queue package.'\n                );\n            }\n\n            $job = CallQueuedClosure::create($job);\n        }\n\n        if ($job instanceof ShouldBeUnique) {\n            return $this->dispatchUniqueJobToQueue($job, $queue, $connection);\n        }\n\n        $this->getDispatcher()->dispatch(\n            $job->onConnection($connection)->onQueue($queue)\n        );\n    }\n\n    /**\n     * Dispatch the given unique job to the queue.","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Console/Scheduling/Schedule.php#L232-L268","documentation":"Thrown by Schedule::dispatchToQueue() (src/Illuminate/Console/Scheduling/Schedule.php:250) when a scheduled closure-based job is dispatched to the queue but CallQueuedClosure (from illuminate/queue) is not present. Closures must be serialized into a CallQueuedClosure object for queue transport.","triggerScenarios":"Schedule::call(fn () => ...)->onQueue(...) or Schedule::job(SomeJob) where the dispatched job ends up being a Closure, in a project where illuminate/queue is not installed (illuminate/bus-only or standalone illuminate/console setup).","commonSituations":"Standalone illuminate/console + illuminate/bus without illuminate/queue; partial Laravel subset for a CLI tool that tries to queue closures.","solutions":["composer require illuminate/queue.","If you don't need queueing, don't queue the closure — run it inline (remove onQueue).","Convert the closure into a real job class implementing ShouldQueue; real classes don't require CallQueuedClosure.","Re-run composer dump-autoload after installing."],"exampleFix":"// before\n$schedule->call(fn () => process())->everyMinute()->onQueue('default');\n// illuminate/queue not installed\n\n// after\n// composer require illuminate/queue\n$schedule->call(fn () => process())->everyMinute()->onQueue('default');\n// or convert to a real job:\n$schedule->job(ProcessJob::class)->everyMinute()->onQueue('default');","handlingStrategy":"validation","validationCode":"if (! class_exists(\\Illuminate\\Queue\\CallQueuedClosure::class)) {\n    // don't queue closures; convert to a job class or install illuminate/queue\n}","typeGuard":"function canQueueClosures(): bool\n{\n    return class_exists(\\Illuminate\\Queue\\CallQueuedClosure::class);\n}","tryCatchPattern":"try {\n    $schedule->call(fn () => work())->onQueue('default');\n} catch (\\RuntimeException $e) {\n    $schedule->call(fn () => work()); // run inline\n}","preventionTips":["Install illuminate/queue when queueing closures.","Convert closures to real ShouldQueue job classes for portability.","Document the illuminate/queue dependency for queue-backed schedules."],"tags":["scheduling","queue","dependency","composer","laravel"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}