{"record":{"id":"b510ffa4e0653f6a","repo":"flarum/framework","slug":"route-name-not-found","errorCode":null,"errorMessage":"Route $name not found","messagePattern":"Route \\$name not found","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"framework/core/src/Http/RouteCollection.php","lineNumber":148,"sourceCode":"            // (which we don't care about here), or an array where the first element is the parameter name\n            // and the second element is a regex into which the parameter value is inserted, if the parameter matches.\n            foreach ($this->reverse[$name] as $parts) {\n                foreach ($parts as $i => $part) {\n                    if ($i > $maxMatches && is_array($part) && Arr::exists($parameters, $part[0])) {\n                        $maxMatches = $i;\n                        $matchingParts = $parts;\n                    }\n                }\n            }\n\n            $fixedParts = array_map(function ($part) use ($parameters, $name) {\n                return $this->fixPathPart($part, $parameters, $name);\n            }, $matchingParts);\n\n            return '/'.ltrim(implode('', $fixedParts), '/');\n        }\n\n        throw new \\RuntimeException(\"Route $name not found\");\n    }\n}\n","sourceCodeStart":130,"sourceCodeEnd":151,"githubUrl":"https://github.com/flarum/framework/blob/4b939f685389bfe8a380e9e28ddf305a1c66950c/framework/core/src/Http/RouteCollection.php#L130-L151","documentation":"RouteCollection::getPath() throws this RuntimeException when the requested route name does not exist in the collection's reverse lookup table ($this->reverse). Route names must be registered first via addRoute()/get()/etc. before URLs can be generated from them.","triggerScenarios":"Calling getPath('someName') where no route named 'someName' was ever registered — typically a typo in the route name, a route registered in a different frontend's RouteCollection, or a removed/renamed route still referenced in templates or controllers.","commonSituations":"Typo in the route name string; using a route registered for the forum frontend inside the admin frontend; an extension that provided the route was disabled or removed; route renamed in a framework upgrade while old references remain.","solutions":["Verify the exact route name by inspecting getRoutes() or the registration code (search for the name string).","Fix the name typo or update the caller to the renamed route.","Register the missing route if it genuinely should exist.","Ensure you call getPath() on the same RouteCollection instance where the route was registered."],"exampleFix":"// before\n$url = $routes->getPath('userr.profile'); // route registered as 'user.profile'\n// after\n$url = $routes->getPath('user.profile');","handlingStrategy":"try-catch","validationCode":"if (!array_key_exists($name, $routes->getRoutes())) {\n    // route unknown: log and skip URL generation\n    return null;\n}\n$url = $routes->getPath($name, $parameters);","typeGuard":"function routeExists(RouteCollection $routes, string $name): bool {\n    return array_key_exists($name, $routes->getRoutes());\n}","tryCatchPattern":"try {\n    $url = $routes->getPath($name, $parameters);\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'not found')) {\n        $url = null; // or fallback URL\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Define route names as class constants shared by registration and generation sites.","Grep for the name string in registration code before using it in getPath().","Remember each frontend (forum/admin/api) has its own RouteCollection."],"tags":["php","routing","route-not-found","url-generation","flarum"],"backgroundTag":"resource-not-found","analyzedSha":"4b939f685389bfe8a380e9e28ddf305a1c66950c","analyzedAt":"2026-09-15T18:09:20.879Z","contentChangedAt":"2026-09-15T18:09:20.879Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}