{"record":{"id":"418f061aec189b16","repo":"twigphp/Twig","slug":"there-are-no-registered-paths-for-namespace-s","errorCode":null,"errorMessage":"There are no registered paths for namespace \"%s\".","messagePattern":"There are no registered paths for namespace \"(.+?)\"\\.","errorType":"exception","errorClass":"LoaderError","httpStatus":null,"severity":"error","filePath":"src/Loader/FilesystemLoader.php","lineNumber":211,"sourceCode":"            [$namespace, $shortname] = $this->parseName($name);\n\n            $this->validateName($shortname);\n        } catch (LoaderError $e) {\n            if (!$throw) {\n                return null;\n            }\n\n            throw $e;\n        }\n\n        if (!isset($this->paths[$namespace])) {\n            $this->errorCache[$name] = \\sprintf('There are no registered paths for namespace \"%s\".', $namespace);\n\n            if (!$throw) {\n                return null;\n            }\n\n            throw new LoaderError($this->errorCache[$name]);\n        }\n\n        foreach ($this->paths[$namespace] as $path) {\n            if (!$this->isAbsolutePath($path)) {\n                $path = $this->rootPath.$path;\n            }\n\n            if (is_file($path.'/'.$shortname)) {\n                if (false !== $realpath = realpath($path.'/'.$shortname)) {\n                    return $this->cache[$name] = $realpath;\n                }\n\n                return $this->cache[$name] = $path.'/'.$shortname;\n            }\n        }\n\n        $this->errorCache[$name] = \\sprintf('Unable to find template \"%s\" (looked into: %s).', $name, implode(', ', $this->paths[$namespace]));\n","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/twigphp/Twig/blob/a414c3a491defb5a60f2fc88ef79ff37c90010cd/src/Loader/FilesystemLoader.php#L193-L229","documentation":"When a namespaced template (@ns/name) is requested but no paths are registered for that namespace, findTemplate() records this error in errorCache and throws it. Namespaces are populated only by addPath()/prependPath() with an explicit namespace argument.","triggerScenarios":"Rendering or loading '@MyNamespace/template.html.twig' when addPath($path, 'MyNamespace') was never called (or called with a different namespace spelling).","commonSituations":"Symfony bundles expecting a namespace registered in twig.paths config; case-sensitive namespace mismatches; forgetting to register an empty namespace for a theme.","solutions":["Register at least one path for the namespace: $loader->addPath($path, 'MyNamespace').","Verify namespace spelling/case matches what's used in the @Namespace/ prefix.","List existing namespaces via getNamespaces() to confirm what is registered."],"exampleFix":"// before\n$twig->render('@Blog/post.html.twig'); // namespace not registered\n// after\n$loader->addPath('/project/blog/templates', 'Blog');\n$twig->render('@Blog/post.html.twig');","handlingStrategy":"validation","validationCode":"$ns = str_starts_with($name, '@') ? substr($name, 1, (int)strpos($name, '/') - 1) : '__main__'; if (!in_array($ns, $loader->getNamespaces(), true)) { throw new \\RuntimeException(\"Namespace '$ns' not registered\"); }","typeGuard":"function namespaceRegistered(Twig\\Loader\\FilesystemLoader $loader, string $name): bool { if ($name[0] ?? '' !== '@') return true; $ns = substr($name, 1, (int)strpos($name, '/') - 1); return in_array($ns, $loader->getNamespaces(), true); }","tryCatchPattern":"try { $twig->render($name); } catch (Twig\\Error\\LoaderError $e) { if (str_contains($e->getMessage(), 'no registered paths')) { // register the namespace path and retry } }","preventionTips":["Register all namespaces in bootstrap config before first render","Assert expected namespaces exist in a smoke test (getNamespaces())","Keep namespace names as constants to avoid case typos"],"tags":["twig","namespace","template-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"a414c3a491defb5a60f2fc88ef79ff37c90010cd","analyzedAt":"2026-09-13T15:10:46.849Z","contentChangedAt":"2026-09-13T15:10:46.849Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}