{"record":{"id":"34eac28540587eaf","repo":"yiisoft/yii2","slug":"method-not-allowed-this-url-can-only-handle-the-f","errorCode":null,"errorMessage":"Method Not Allowed. This URL can only handle the following request methods: implode(', ', $allowed).","messagePattern":"Method Not Allowed\\. This URL can only handle the following request methods: implode\\(', ', \\$allowed\\)\\.","errorType":"http","errorClass":"MethodNotAllowedHttpException","httpStatus":405,"severity":"error","filePath":"framework/filters/VerbFilter.php","lineNumber":112,"sourceCode":"     */\n    public function beforeAction($event)\n    {\n        $action = $event->action->id;\n        if (isset($this->actions[$action])) {\n            $verbs = $this->actions[$action];\n        } elseif (isset($this->actions['*'])) {\n            $verbs = $this->actions['*'];\n        } else {\n            return $event->isValid;\n        }\n\n        $verb = Yii::$app->getRequest()->getMethod();\n        $allowed = array_map('strtoupper', $verbs);\n        if (!in_array($verb, $allowed)) {\n            $event->isValid = false;\n            // https://tools.ietf.org/html/rfc2616#section-14.7\n            Yii::$app->getResponse()->getHeaders()->set('Allow', implode(', ', $allowed));\n            throw new MethodNotAllowedHttpException('Method Not Allowed. This URL can only handle the following request methods: ' . implode(', ', $allowed) . '.');\n        }\n\n        return $event->isValid;\n    }\n}\n","sourceCodeStart":94,"sourceCodeEnd":118,"githubUrl":"https://github.com/yiisoft/yii2/blob/66f00d18a29b520f85e8e8f1e32d1e7e7b556cac/framework/filters/VerbFilter.php#L94-L118","documentation":"Error \"Method Not Allowed. This URL can only handle the following request methods: implode(', ', $allowed).\" thrown in yiisoft/yii2.","triggerScenarios":"Thrown at framework/filters/VerbFilter.php:112 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"66f00d18a29b520f85e8e8f1e32d1e7e7b556cac","analyzedAt":"2026-08-17T05:17:23.470Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}