notfoundhttpexception in routecollection.php,NotFoundHttpException in RouteCollection.php line 161 i...

问题

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 () {

//

});

And I am getting this error when I browse to /laravel/user/5/

Sorry, the page you are looking for could not be found.

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.

and a bunch of other errors.

Is anything wrong in my route configuration?

回答1:

This problem is because when installed laravel through command promot i ran "composer create-project laravel/laravel –-prefer-dist" as the document suggest.

so actually correct command is "composer create-project laravel/laravel yourProjectName"

回答2:

my problem was in the virtual server definition where I have defined in the laravel folder as document root in the apache virtual server setup file,

I was getting the error while accessing

localhost:9000/laravel/api/courselist

once I changed it to

localhost:9000/api/courselist

I started getting the proper response

来源:https://stackoverflow.com/questions/42412909/notfoundhttpexception-in-routecollection-php-line-161-in-laravel

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值