首页 > 解决方案 > Laravel 不支持 DELETE & PUT 请求?

问题描述

建立我的API结果是,如果我正在使用DELETEPUT请求 Laravel throws 405 Error (Method Not Allowed)。如何让它发挥作用?

Laravel 错误:

Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException 此路由不支持 PUT 方法。支持的方法:GET、HEAD。

标签: phplaravelrest

解决方案


Laravel 确实支持 DELETE 和 PUT。您定义了错误的路线,它只允许 GET-Requests。

Route::put('/put', 'Controller@function');
Route::delete('/delete', 'Controller@function');

在此处查看文档


推荐阅读