flarum/framework · error · RouteNotFoundException

RouteNotFoundException ($uri)

Error message

RouteNotFoundException ($uri)

What it means

Thrown in ResolveRoute::process when FastRoute's dispatcher returns NOT_FOUND for the request method + URI: no registered route matches the path (after trailing-slash stripping). This is the middleware-level signal that the client requested a nonexistent endpoint; it surfaces as a 404. It is a routing sentinel for unmatched URLs, not a handler error.

Solutions

  1. Check the request path for typos and confirm the endpoint exists
  2. Register a route for the path if it is a new endpoint (Extend\Routes)
  3. If a frontend link leads here, the route it was generated from may be stale or removed by a disabled extension
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at framework/core/src/Http/Middleware/ResolveRoute.php:50 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of flarum/framework@4b939f6853 (2026-09-15). Data as JSON: /api/errors/9b365df0e26b7b75. Report an issue: GitHub.

Appendix: source

Thrown at framework/core/src/Http/Middleware/ResolveRoute.php:50

     *
     * @throws MethodNotAllowedException
     * @throws RouteNotFoundException
     */
    public function process(Request $request, Handler $handler): Response
    {
        $method = $request->getMethod();
        $uri = $request->getUri()->getPath() ?: '/';

        // Strip trailing slash so that e.g. /d/123-slug/ resolves the same as /d/123-slug.
        if ($uri !== '/' && str_ends_with($uri, '/')) {
            $uri = rtrim($uri, '/');
        }

        $routeInfo = $this->getDispatcher()->dispatch($method, $uri);

        switch ($routeInfo[0]) {
            case Dispatcher::NOT_FOUND:
                throw new RouteNotFoundException($uri);
            case Dispatcher::METHOD_NOT_ALLOWED:
                throw new MethodNotAllowedException($method);
            default:
                $request = $request
                    ->withAttribute('routeName', $routeInfo[1]['name'])
                    ->withAttribute('routeHandler', $routeInfo[1]['handler'])
                    ->withAttribute('routeParameters', $routeInfo[2]);

                return $handler->handle($request);
        }
    }

    protected function getDispatcher(): Dispatcher\GroupCountBased
    {
        if (! isset($this->dispatcher)) {
            $this->dispatcher = new Dispatcher\GroupCountBased($this->routes->getRouteData());
        }

View on GitHub (pinned to 4b939f6853)