{"record":{"id":"ec5d09ba40cdcdd8","repo":"twigphp/Twig","slug":"unable-to-find-template-s-looked-into-s","errorCode":null,"errorMessage":"Unable to find template \"%s\" (looked into: %s).","messagePattern":"Unable to find template \"(.+?)\" \\(looked into: (.+?)\\)\\.","errorType":"exception","errorClass":"LoaderError","httpStatus":null,"severity":"error","filePath":"src/Loader/FilesystemLoader.php","lineNumber":234,"sourceCode":"                $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\n        if (!$throw) {\n            return null;\n        }\n\n        throw new LoaderError($this->errorCache[$name]);\n    }\n\n    private function normalizeName(string $name): string\n    {\n        return preg_replace('#/{2,}#', '/', str_replace('\\\\', '/', $name));\n    }\n\n    private function parseName(string $name, string $default = self::MAIN_NAMESPACE): array\n    {\n        if (isset($name[0]) && '@' == $name[0]) {\n            if (false === $pos = strpos($name, '/')) {\n                throw new LoaderError(\\sprintf('Malformed namespaced template name \"%s\" (expecting \"@namespace/template_name\").', $name));\n            }\n\n            $namespace = substr($name, 1, $pos - 1);\n            $shortname = substr($name, $pos + 1);\n\n            return [$namespace, $shortname];","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/twigphp/Twig/blob/a414c3a491defb5a60f2fc88ef79ff37c90010cd/src/Loader/FilesystemLoader.php#L216-L252","documentation":"findTemplate() searched every registered path for the namespace and found no file matching the template name. The thrown message lists all directories that were looked into, and the failure is memoized in errorCache for subsequent lookups of the same name.","triggerScenarios":"Calling render()/getSourceContext()/getCacheKey()/exists() for a template whose file does not exist in any registered path — wrong filename, wrong extension, or file simply missing.","commonSituations":"Missing file after deploy; case-sensitivity differences between local (case-insensitive FS) and production (Linux); wrong template extension; templates stored outside registered paths.","solutions":["Create the template file in one of the directories listed in 'looked into:'.","Fix the template name (spelling, extension, case) to match the actual file.","Add the directory containing the file via addPath().","Check filename case matches exactly — production filesystems are case-sensitive."],"exampleFix":"// before\n$twig->render('user/Profile.html.twig'); // actual file is profile.html.twig\n// after\n$twig->render('user/profile.html.twig');","handlingStrategy":"try-catch","validationCode":"if (!$loader->exists($name)) { // surface a friendly 404 or fallback instead of a raw LoaderError }","typeGuard":null,"tryCatchPattern":"try { return $twig->render($name, $ctx); } catch (Twig\\Error\\LoaderError $e) { if (str_contains($e->getMessage(), 'Unable to find template')) { return $twig->render('errors/404.html.twig'); } throw $e; }","preventionTips":["Add template existence to deployment smoke tests","Standardize extensions and naming conventions","Map template names via constants/DTOs instead of ad-hoc strings","Check the 'looked into' list to register missing directories"],"tags":["twig","filesystem","template-not-found"],"backgroundTag":"file-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"}