“哎呀,看起来出事了。” Laravel 4.1

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23849311/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 09:33:24  来源:igfitidea点击:

"Whoops, looks like something went wrong." Laravel 4.1

phplaravellaravel-4url-routing

提问by user3263978

Okay, so I've just gotten around to checking out Laravel 4.1, I've hit a problem and I don't understand why? The problem is that I get this message on the screen "Whoops, looks like something went wrong." but I haven't really done anything. I've created a view, a controller and added a route and this is what is in these files

好的,所以我刚刚开始检查 Laravel 4.1,我遇到了一个问题,我不明白为什么?问题是我在屏幕上收到这条消息“哎呀,好像出了点问题。” 但我真的什么都没做。我创建了一个视图、一个控制器并添加了一个路由,这就是这些文件中的内容

VIEW

看法

<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
    }
}

and ROUTE

路线

Route::get('authors', 'AuthorsController@getIndex'); 

So logic dictates that when I go to the authors URL it should load the getIndex function within the AurhorsController page and show the index.blade.php file which is in views > authors.

所以逻辑规定,当我转到作者 URL 时,它应该在 AurhorsController 页面中加载 getIndex 函数并显示在视图 > 作者中的 index.blade.php 文件。

If so then I have no idea why this is not working! any help would be appreciated. Thanks in advance.

如果是这样,那么我不知道为什么这不起作用!任何帮助,将不胜感激。提前致谢。

EDIT 1

编辑 1

This is the actual error

这是实际的错误

throw new NotFoundHttpException();

EDIT 2

编辑 2

Trace

痕迹

采纳答案by The Alpha

You should remove public $restful = true;but it's not a problem for NotFoundHttpException

你应该删除,public $restful = true;但这不是问题NotFoundHttpException

// Path: app/controllers/AuthorsController.php
class AuthorsController extends BaseController {

    // public $restful = true;

    public function getIndex () {
        return View::make('authors.index');
    }
}

According to your routegiven below:

根据你route给出的如下:

Route::get('authors', 'AuthorsController@getIndex');

It should work if you make a GETrequest, make sure you made the request from browser's address bar and urlwas like yourdomain.dev/authorsor http://localhost/yourapp/authors. Also you may run following command from command prompt/terminal (within your project directory):

如果您发出GET请求,它应该可以工作,请确保您从浏览器的地址栏发出请求并且urlyourdomain.dev/authorshttp://localhost/yourapp/authors。您也可以从命令提示符/终端(在您的项目目录中)运行以下命令:

composer dump-autoload

回答by Joel Hinz

Looks like Laravel's trying to access the public folder and fails, because there's no file named authorsin that folder, and also no route named public/authors. You'll want to go to http://localhost:8081/branch/authorsinstead, assuming that your installation resides in http://localhost:8081/branch.

看起来 Laravel 试图访问公共文件夹并失败了,因为authors该文件夹中没有命名的文件,也没有名为public/authors. 你会想去http://localhost:8081/branch/authors相反,假设你安装寓于http://localhost:8081/branch