Laravel 中 RouteCollection.php 第 161 行中的 NotFoundHttpException [英] NotFoundHttpException in RouteCollection.php line 161 in laravel
问题描述
我在 routes.php
中添加了以下路由:
I added the following routes in routes.php
:
Route::get('/', function () {
return 'Hello World';
});
Route::get('user/{id}', function ($id) {
return 'User '.$id;
});
Route::post('foo/bar', function () {
return 'Hello World';
});
Route::put('foo/bar', function () {
//
});
Route::delete('foo/bar', function () {
//
});
当我浏览到 /laravel/user/5/
抱歉,找不到您要查找的页面.
NotFoundHttpException in RouteCollection.php line 161:1) inRouteCollection.php 行 161.2) 在Router.php 第 533 行中的 RouteCollection-match(object(Request))Router-findRoute(object(Request)) 在 Router.php 第 512 行.
NotFoundHttpException in RouteCollection.php line 161:1) in RouteCollection.php line 161.2) at RouteCollection-match(object(Request)) in Router.php line 533 at Router-findRoute(object(Request)) in Router.php line 512.
还有一堆其他错误.
我的路由配置有问题吗?
Is anything wrong in my route configuration?
推荐答案
这个问题是因为当通过命令 promot 安装 laravel 时,我按照文档的建议运行了composer create-project laravel/laravel --prefer-dist".
This problem is because when installed laravel through command promot i ran "composer create-project laravel/laravel –-prefer-dist" as the document suggest.
所以实际上正确的命令是composer create-project laravel/laravel yourProjectName"
so actually correct command is "composer create-project laravel/laravel yourProjectName"
这篇关于Laravel 中 RouteCollection.php 第 161 行中的 NotFoundHttpException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!