{"record":{"id":"0a91fd13870680dc","repo":"symfony/http-kernel","slug":"message-built-by-getcontrollererror-e-g-function-s-does-not","errorCode":null,"errorMessage":"Message built by getControllerError(): e.g. Function \"%s\" does not exist. / Controller class \"%s\" cannot be called without a method name. You need to implement \"__invoke\". / Class \"%s\" does not exist.","messagePattern":"Message built by getControllerError\\(\\): e\\.g\\. Function \"(.+?)\" does not exist\\. / Controller class \"(.+?)\" cannot be called without a method name\\. You need to implement \"__invoke\"\\. / Class \"(.+?)\" does not exist\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Controller/ControllerResolver.php","lineNumber":118,"sourceCode":"        if (!\\is_callable($callable)) {\n            throw new \\InvalidArgumentException(\\sprintf('The controller for URI \"%s\" is not callable: ', $request->getPathInfo()).$this->getControllerError($callable));\n        }\n\n        return $this->checkController($request, $callable);\n    }\n\n    /**\n     * Returns a callable for the given controller.\n     *\n     * @throws \\InvalidArgumentException When the controller cannot be created\n     */\n    protected function createController(string $controller): callable\n    {\n        if (!str_contains($controller, '::')) {\n            $controller = $this->instantiateController($controller);\n\n            if (!\\is_callable($controller)) {\n                throw new \\InvalidArgumentException($this->getControllerError($controller));\n            }\n\n            return $controller;\n        }\n\n        [$class, $method] = explode('::', $controller, 2);\n\n        try {\n            $controller = [$this->instantiateController($class), $method];\n        } catch (\\Error|\\LogicException $e) {\n            try {\n                if ((new \\ReflectionMethod($class, $method))->isStatic()) {\n                    return $class.'::'.$method;\n                }\n            } catch (\\ReflectionException) {\n                throw $e;\n            }\n","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/symfony/http-kernel/blob/aa3a39d7286a62cdfea98f0e69c651a3da6e36cf/Controller/ControllerResolver.php#L100-L136","documentation":"Symfony's ControllerResolver fails to turn a controller string into a callable, so it throws InvalidArgumentException with a message produced by getControllerError(). The message tells you whether the function/class does not exist, or whether the class is not callable without a method name (no __invoke). It is thrown in createController() when the controller string contains no '::' and instantiating it does not yield something callable.","triggerScenarios":"Route/service configured with a controller string like 'App\\Controller\\FooController' where the class does not exist, is not registered as a service (controller.service_arguments), or lacks a default method and does not implement __invoke(); passing a non-callable value to the resolver directly.","commonSituations":"Typo in controller class name in routes.yaml/attributes; controller class defined but not tagged for the service container (missing services.yaml autoconfigure); class exists but expects constructor arguments not resolvable from the container; framework version upgrade changing how controllers are resolved.","solutions":["Check that the controller string matches an existing class (correct namespace and spelling) and is a real class, not an abstract/interface.","If the controller is a service, ensure the class is autowired/autoconfigured in services.yaml and the class implements __invoke or the route names a method via 'Class::method'.","Run `php bin/console debug:router` and `php bin/console debug:container <class>` to verify the controller resolves.","Add a __invoke() method or an explicit '::method' suffix to the controller definition."],"exampleFix":"// before: routes.yaml\napp_foo:\n    path: /foo\n    controller: App\\Controller\\FooController\n// after\napp_foo:\n    path: /foo\n    controller: App\\Controller\\FooController::index","handlingStrategy":"validation","validationCode":"if (!class_exists($controllerClass) && !str_contains($controllerString, '::')) {\n    throw new \\InvalidArgumentException(sprintf('Controller \"%s\" must be \"Class::method\" or implement __invoke().', $controllerString));\n}","typeGuard":"if (!\\is_callable([$controllerClass, $method]) && !\\is_callable([new $controllerClass(), '__invoke'])) {\n    return null; // not a resolvable controller\n}","tryCatchPattern":"try {\n    $controller = $resolver->getController($request);\n} catch (\\InvalidArgumentException $e) {\n    $logger->error('Unresolvable controller: '.$e->getMessage());\n    return new Response('Not Found', 404);\n}","preventionTips":["Always use 'Class::method' syntax or #[Route] attributes so the controller is explicit.","Verify controllers with `php bin/console debug:router` after adding routes.","Keep services.yaml autoconfigure/auto-wiring of controller classes enabled.","Add a smoke test that matches every route name against class_exists + method_exists."],"tags":["symfony","routing","controller","invalid-argument"],"backgroundTag":"invalid-argument","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"}