【发布时间】:2017-10-06 08:13:41
【问题描述】:
使用 Laravel 5.4 在 web.php 中有这条路线
Route::post('foo/bar', function () {
return 'Hello World';
});
但是当我在浏览器中访问http://localhost:8000/foo/bar URL 时出现此错误:
RouteCollection.php 第 251 行中的 MethodNotAllowedHttpException:在 RouteCollection.php 第 251 行 RouteCollection->methodNotAllowed(array('POST')) in RouteCollection.php 第 238 行 RouteCollection->getRouteForMethods(object(Request), array('POST')) in RouteCollection.php 第 176 行 Router.php 第 533 行中的 RouteCollection->match(object(Request)) ...
我想通过浏览器测试一个 POST 路由方法。
【问题讨论】:
-
使用某种测试扩展。我在 Chrome 上使用 Postman 并且它可以工作(不是 100% 满意,但它可以完成工作)。或者,您可以在 Laravel 内置测试工具上使用 cURL。
标签: php laravel-5 routes http-post