[英]“Whoops, looks like something went wrong.” Laravel 4.1
好的,所以我刚刚开始研究Laravel 4.1,我遇到了一个问题,我不明白为什么? 问题是我在屏幕上收到此消息,“糟糕,好像出了点问题。” 但是我真的什么都没做。 我已经创建了一个视图,一个控制器并添加了一条路线,这就是这些文件中的内容
视图
<h1>Author's home page</h1>
CONTROLLER
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
看起来Laravel尝试访问公用文件夹失败,因为该文件夹中没有名为authors
的文件,也没有名为public/authors
路由。 假设您的安装位于http://localhost:8081/branch
,您将转而转到http://localhost:8081/branch/authors
。
您应该删除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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.