{"record":{"id":"bf26e5bbf778b9b9","repo":"symfony/http-kernel","slug":"the-controller-for-uri-s-is-not-callable","errorCode":null,"errorMessage":"The controller for URI \"%s\" is not callable: ","messagePattern":"The controller for URI \"(.+?)\" is not callable: ","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Controller/ControllerResolver.php","lineNumber":76,"sourceCode":"\n            return false;\n        }\n\n        if (\\is_array($controller)) {\n            if (isset($controller[0]) && \\is_string($controller[0]) && isset($controller[1])) {\n                try {\n                    $controller[0] = $this->instantiateController($controller[0]);\n                } catch (\\Error|\\LogicException $e) {\n                    if (\\is_callable($controller)) {\n                        return $this->checkController($request, $controller);\n                    }\n\n                    throw $e;\n                }\n            }\n\n            if (!\\is_callable($controller)) {\n                throw new \\InvalidArgumentException(\\sprintf('The controller for URI \"%s\" is not callable: ', $request->getPathInfo()).$this->getControllerError($controller));\n            }\n\n            return $this->checkController($request, $controller);\n        }\n\n        if (\\is_object($controller)) {\n            if (!\\is_callable($controller)) {\n                throw new \\InvalidArgumentException(\\sprintf('The controller for URI \"%s\" is not callable: ', $request->getPathInfo()).$this->getControllerError($controller));\n            }\n\n            return $this->checkController($request, $controller);\n        }\n\n        if (\\function_exists($controller)) {\n            return $this->checkController($request, $controller);\n        }\n\n        try {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/symfony/http-kernel/blob/aa3a39d7286a62cdfea98f0e69c651a3da6e36cf/Controller/ControllerResolver.php#L58-L94","documentation":"ControllerResolver::getController resolved the _controller attribute from the Request, but the resulting value is not callable. The message is appended with getControllerError() explaining why (e.g. class does not exist, method missing).","triggerScenarios":"Request attributes contain a _controller value that resolves to a string or array that is_callable() rejects: a non-existent class::method, an instantiated object with an undefined method, or a malformed 'Class::method' string when the controller was found via the fallback path (not createController).","commonSituations":"Typo in _controller name in route annotations/attributes or YAML; controller method renamed or made private; controller string like 'App\\\\Controller\\\\Foo::bar' where class exists but ::bar does not; using a service method string without container support.","solutions":["Fix the _controller value in the route definition to an existing, public, callable controller","Check the appended detail from getControllerError() to see whether the class or the method is missing","Clear the cache (cache:clear) so compiled route/controller data matches current code","If using a service controller, ensure the service exists and use 'serviceId::method' or 'serviceId:methodName' syntax"],"exampleFix":"// before\n#[Route('/foo', name: 'foo', '_controller' => 'App\\\\Controller\\\\FooControler::index')]\n// after\n#[Route('/foo', name: 'foo', '_controller' => 'App\\\\Controller\\\\FooController::index')]\n","handlingStrategy":"validation","validationCode":"$ctrl = $request->attributes->get('_controller');\nif (is_string($ctrl) && !is_callable($ctrl, true)) {\n    [$class, $method] = array_pad(explode('::', $ctrl, 2), 2, '__invoke');\n    if (!class_exists($class) || !method_exists($class, $method)) {\n        throw new \\InvalidArgumentException(\"Controller '$ctrl' is not callable\");\n    }\n}","typeGuard":"function isStringCallableController(mixed $c): bool { return is_string($c) && is_callable($c, true); }","tryCatchPattern":"try { $controller = $resolver->getController($request); } catch (\\InvalidArgumentException $e) {\n    // 'The controller for URI ... is not callable'\n}","preventionTips":["Use #[Route('/x', name: 'x')] attributes without manual _controller strings where possible","Use bin/console debug:router and lint:container to validate routes and controllers","Keep action methods public","Clear cache after renaming controllers or methods"],"tags":["symfony","controller","routing","callable"],"backgroundTag":"invalid-identifier","analyzedSha":"aa3a39d7286a62cdfea98f0e69c651a3da6e36cf","analyzedAt":"2026-09-13T18:03:36.509Z","contentChangedAt":"2026-09-13T18:03:36.509Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}