好的,所以我刚刚开始研究Laravel 4.1,我遇到了一个问题,我不明白为什么?问题是我在屏幕上收到此消息:“糟糕,好像出了点问题。” 但是我还没有真正做任何事情。我已经创建了一个视图,一个控制器并添加了一条路线,这就是这些文件中的内容
看法
<h1>Author's home page</h1>
控制器
class AuthorsController extends BaseController {
public $restful = true;
public function getIndex () {
return View::make('authors.index'); //authors.index because it's in the authors folder within the views folder
}
}
和ROUTE
Route::get('authors', 'AuthorsController@getIndex');
因此逻辑要求,当我转到作者URL时,应在AurhorsController页面中加载getIndex函数,并在“视图”>“作者”中显示index.blade.php文件。
如果是这样,那么我不知道为什么这行不通!任何帮助,将不胜感激。提前致谢。
编辑1
这是实际的错误
throw new NotFoundHttpException();
编辑2
您应该删除,public $restful = true;
但这不是问题NotFoundHttpException
// Path: app/controllers/AuthorsController.php
class AuthorsController extends BaseController {
// public $restful = true;
public function getIndex () {
return View::make('authors.index');
}
}
根据您route
给定的如下:
Route::get('authors', 'AuthorsController@getIndex');
如果您发出GET
请求,它应该可以工作,请确保您是从浏览器的地址栏中发出请求的,并且url
类似于yourdomain.dev/authors
或http://localhost/yourapp/authors
。您也可以从命令提示符/终端(在项目目录中)运行以下命令:
composer dump-autoload
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句