{"record":{"id":"069e3ed10b9d9141","repo":"laravel/framework","slug":"queue-resolver-did-not-return-a-queue-implementati","errorCode":null,"errorMessage":"Queue resolver did not return a Queue implementation.","messagePattern":"Queue resolver did not return a Queue implementation\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Bus/Dispatcher.php","lineNumber":269,"sourceCode":"\n    /**\n     * Dispatch a command to its appropriate handler behind a queue.\n     *\n     * @param  mixed  $command\n     * @return mixed\n     *\n     * @throws \\RuntimeException\n     */\n    public function dispatchToQueue($command)\n    {\n        $connection = $this->getAttributeValue($command, Connection::class, 'connection')\n            ?? $this->resolveConnectionFromQueueRoute($command)\n            ?? null;\n\n        $queue = ($this->queueResolver)($connection);\n\n        if (! $queue instanceof Queue) {\n            throw new RuntimeException('Queue resolver did not return a Queue implementation.');\n        }\n\n        if (method_exists($command, 'queue')) {\n            return $command->queue($queue, $command);\n        }\n\n        return $this->pushCommandToQueue($queue, $command);\n    }\n\n    /**\n     * Push the command onto the given queue instance.\n     *\n     * @param  \\Illuminate\\Contracts\\Queue\\Queue  $queue\n     * @param  mixed  $command\n     * @return mixed\n     */\n    protected function pushCommandToQueue($queue, $command)\n    {","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Bus/Dispatcher.php#L251-L287","documentation":"Dispatcher::dispatchToQueue resolves the queue implementation by invoking the queueResolver closure (bound by the BusServiceProvider) with the command's connection name. If that closure returns null or anything not implementing Illuminate\\Contracts\\Queue\\Queue, dispatch cannot proceed. This is a container wiring / service provider failure rather than a per-job problem.","triggerScenarios":"Calling Bus::dispatch($command) or dispatch($command) on a job implementing ShouldQueue when: the QueueServiceProvider is not registered, the container binding 'queue' was overridden or unbound, Bus::dispatchToQueue was invoked manually with a custom queueResolver returning null, or running outside a booted Laravel app (e.g., in a bare PHPUnit test bootstrapping only the Bus service provider).","commonSituations":"Using illuminate/bus as a standalone Composer dependency without illuminate/queue and the QueueServiceProvider. Testing a job via Bus::fake() replacement that was misconfigured. Overriding the 'queue' binding in a service provider with a factory that returns null on misconfiguration. App not fully booted in a long-running daemon (e.g., Laravel Octane reload race).","solutions":["Ensure Illuminate\\Queue\\QueueServiceProvider is registered in config/app.php (or bootstrap/app.php for Laravel 11+) alongside the BusServiceProvider.","Verify the 'queue' container binding resolves to an Illuminate\\Queue\\QueueManager instance: app('queue') instanceof QueueManager.","If using illuminate/bus standalone, register a queueResolver closure via the Dispatcher constructor or via Bus::dispatchUsingQueue($resolver) that returns a valid Queue.","Check for service provider overrides in bootstrap/app.php or custom Application subclasses that unbind 'queue'."],"exampleFix":"// before (standalone illuminate/bus usage)\n$dispatcher = new Dispatcher(new Container());\n$dispatcher->dispatch(new SendInvoice($order)); // RuntimeException\n\n// after\n$container = new Container();\n$container->instance('queue', new SyncQueue($container));\n$dispatcher = new Dispatcher($container, fn ($c) => $container['queue']);\n$dispatcher->dispatch(new SendInvoice($order));","handlingStrategy":"validation","validationCode":"// Validate the queue resolver returns a Queue before dispatching\n$dispatcher = app(\\Illuminate\\Contracts\\Bus\\Dispatcher::class);\n$resolved = app('queue');\nif (! $resolved instanceof \\Illuminate\\Contracts\\Queue\\Queue) {\n    throw new \\RuntimeException('Container \"queue\" binding does not resolve to a Queue instance.');\n}\n$dispatcher->dispatch($command);","typeGuard":"function queueResolverIsBound(\\Illuminate\\Container\\Container $container): bool\n{\n    return $container->bound('queue')\n        && $container->make('queue') instanceof \\Illuminate\\Contracts\\Queue\\Queue;\n}","tryCatchPattern":null,"preventionTips":["Ensure QueueServiceProvider is always registered alongside BusServiceProvider in your bootstrap.","In standalone illuminate/bus usage, pass an explicit queueResolver Closure to the Dispatcher constructor.","Add a boot-time assertion: abort_unless(app('queue') instanceof \\Illuminate\\Contracts\\Queue\\Queue, 500, 'Queue not bound.');","Avoid unbinding 'queue' in service providers; if you must override, rebind to a valid Queue."],"tags":["bus","queue","container","service-provider"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}