{"record":{"id":"c85ea92e7ea33484","repo":"flarum/framework","slug":"methodnotallowedexception-method","errorCode":null,"errorMessage":"MethodNotAllowedException ($method)","messagePattern":"MethodNotAllowedException \\(\\$method\\)","errorType":"http","errorClass":"MethodNotAllowedException","httpStatus":405,"severity":"error","filePath":"framework/core/src/Http/Middleware/ResolveRoute.php","lineNumber":52,"sourceCode":"     * @throws RouteNotFoundException\n     */\n    public function process(Request $request, Handler $handler): Response\n    {\n        $method = $request->getMethod();\n        $uri = $request->getUri()->getPath() ?: '/';\n\n        // Strip trailing slash so that e.g. /d/123-slug/ resolves the same as /d/123-slug.\n        if ($uri !== '/' && str_ends_with($uri, '/')) {\n            $uri = rtrim($uri, '/');\n        }\n\n        $routeInfo = $this->getDispatcher()->dispatch($method, $uri);\n\n        switch ($routeInfo[0]) {\n            case Dispatcher::NOT_FOUND:\n                throw new RouteNotFoundException($uri);\n            case Dispatcher::METHOD_NOT_ALLOWED:\n                throw new MethodNotAllowedException($method);\n            default:\n                $request = $request\n                    ->withAttribute('routeName', $routeInfo[1]['name'])\n                    ->withAttribute('routeHandler', $routeInfo[1]['handler'])\n                    ->withAttribute('routeParameters', $routeInfo[2]);\n\n                return $handler->handle($request);\n        }\n    }\n\n    protected function getDispatcher(): Dispatcher\\GroupCountBased\n    {\n        if (! isset($this->dispatcher)) {\n            $this->dispatcher = new Dispatcher\\GroupCountBased($this->routes->getRouteData());\n        }\n\n        return $this->dispatcher;\n    }","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/flarum/framework/blob/4b939f685389bfe8a380e9e28ddf305a1c66950c/framework/core/src/Http/Middleware/ResolveRoute.php#L34-L70","documentation":"Thrown in ResolveRoute::process when FastRoute returns METHOD_NOT_ALLOWED: the URI matches a registered route but the HTTP verb (e.g. DELETE on a GET/POST-only route) is not in that route's allowed methods list. Surfaces as 405; the message names the offending method. Flarum routes typically allow only GET and POST, so other verbs indicate a client using verbs the route does not declare.","triggerScenarios":"Thrown at framework/core/src/Http/Middleware/ResolveRoute.php:52 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the HTTP method the route was registered with (usually GET or POST in Flarum)","Check the route definition in Extend\\Routes to see which verbs it accepts","Fix client code or library configuration that issues the wrong verb"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}