{"record":{"id":"70dc0f70e11a869a","repo":"laravel/framework","slug":"given-channel-handler-is-an-unknown-type","errorCode":null,"errorMessage":"Given channel handler is an unknown type.","messagePattern":"Given channel handler is an unknown type\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php","lineNumber":167,"sourceCode":"    }\n\n    /**\n     * Extracts the parameters out of what the user passed to handle the channel authentication.\n     *\n     * @param  callable|string  $callback\n     * @return \\ReflectionParameter[]\n     *\n     * @throws \\Exception\n     */\n    protected function extractParameters($callback)\n    {\n        if (is_callable($callback)) {\n            return (new ReflectionFunction($callback))->getParameters();\n        } elseif (is_string($callback)) {\n            return $this->extractParametersFromClass($callback);\n        }\n\n        throw new Exception('Given channel handler is an unknown type.');\n    }\n\n    /**\n     * Extracts the parameters out of a class channel's \"join\" method.\n     *\n     * @param  string  $callback\n     * @return \\ReflectionParameter[]\n     *\n     * @throws \\Exception\n     */\n    protected function extractParametersFromClass($callback)\n    {\n        $reflection = new ReflectionClass($callback);\n\n        if (! $reflection->hasMethod('join')) {\n            throw new Exception('Class based channel must define a \"join\" method.');\n        }\n","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php#L149-L185","documentation":"Thrown by Broadcaster::extractParameters() when a channel authorization/callback handler is neither a PHP callable nor a string (the latter being a 'Class@method' or class name resolved via extractParametersFromClass). The broadcaster inspects handlers' parameter signatures to auto-inject route-binding values, so an unrecognizable handler type cannot be reflected.","triggerScenarios":"Registering a channel closure/handler via Broadcast::channel('channel', $callback) (or Channel:: routes) with a value that is not callable and not a string — e.g. null, an integer, a non-invokable object, or an array that isn't a valid callable.","commonSituations":"Passing an instance instead of a class string for a class-based channel; passing null because a config/factory returned nothing; passing an array like ['Controller','method'] where the controller isn't autoloadable so is_callable is false; typos in 'Class@method'.","solutions":["Pass a closure: Broadcast::channel('order.{id}', fn (\\App\\Models\\Order $order) => ...);","Pass a class string for a class-based channel: Broadcast::channel('order.{id}', \\App\\Broadcasting\\OrderChannel::class);","Pass a valid 'Class@method' string: Broadcast::channel('order.{id}', 'OrderChannel@join');","Verify the value is callable or a string before registering the channel."],"exampleFix":"// before — passing a non-invokable object\nBroadcast::channel('order.{id}', app(\\App\\Broadcasting\\OrderPolicy::class));\n\n// after — pass the class string for a class-based channel\nBroadcast::channel('order.{id}', \\App\\Broadcasting\\OrderChannel::class);\n// where OrderChannel has a public function join(\\App\\Models\\Order $order, $id) { ... }","handlingStrategy":"validation","validationCode":"// PHP — validate the channel handler before registering\nfunction isValidChannelHandler($callback): bool {\n    return is_callable($callback) || is_string($callback);\n}\nif (! isValidChannelHandler($callback)) {\n    throw new \\InvalidArgumentException('Channel handler must be a callable or a class/method string.');\n}\nBroadcast::channel('order.{id}', $callback);","typeGuard":"function isValidChannelHandler($callback): bool {\n    return is_callable($callback) || is_string($callback);\n}","tryCatchPattern":"try {\n    Broadcast::channel('order.{id}', $callback);\n} catch (\\Exception $e) {\n    report('Invalid channel handler: '.$e->getMessage());\n    throw $e;\n}","preventionTips":["Register channels with closures or class strings (class-based channels).","Validate handler type when loading channels from config.","Use static analysis to ensure Broadcast::channel receives a callable or string."],"tags":["broadcasting","channels","laravel","php"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}