刚刚从Raphael Saunier获得"Laravel4入门"电子书 并尝试了教程,同时编写Route::get in routes。php的 我有一个错误说,

Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException

当我这样写代码的时候

Route::get('cats/{cat}', function($cat){
    return View::make('cats.single')->with('cat', $cat);
});

Route::get('cats/create', function() {
$cat = new Cat;
return View::make('cats.edit')
->with('cat', $cat)
->with('method', 'post');
});

但是从packtpub下载源文件后,我交叉检查所有代码完全相同,但只有序列不同,如下所示

Route::get('cats/create', function() {
$cat = new Cat;
return View::make('cats.edit')
->with('cat', $cat)
->with('method', 'post');
});

Route::get('cats/{cat}', function($cat){
    return View::make('cats.single')->with('cat', $cat);
});

像这样的路由序列差异在路由上是否重要。php?我怎么能现在的错误是从路由序列?

有帮助吗?

解决方案

是的.顺序肯定很重要。一旦路由与您当前的url匹配,其余的路由将不再被检查。

Route::get('cats/{cat}', ...) 比赛对 cats/ +任何东西,它还包括 cats/create.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top