【发布时间】:2014-05-19 20:58:03
【问题描述】:
我的 app/start/global.php 文件中有以下代码:
App::missing(function($exception){
return Response::view('missing', array('url' => Request::url()), 404);
});
我在 app/view 中有一个名为 missing.blade.php 的文件。但是,上面的代码给了我一个 FatalErrorException,告诉我“调用非对象上的成员函数 getPath()”。我从中获得上述信息的其他漂亮错误页面的格式也搞砸了。
但是当我将 global.php 中的代码更改为以下内容时,一切正常:
App::missing(function($exception){
return Response::make("Page not found", 404);
});
我不明白发生了什么。找不到路线时如何显示特定视图?
编辑: 这是我的missing.blade.php 文件:
@extends('master')
@section('header')
<h2>404 Error</h2>
@stop
@section('content')
<p>
Unable to locate page.
</p>
@stop
编辑 2: 同样在我的 app/views 文件夹中,我有一个 master.blade.php 文件,其结构如下:
...
@yield('header')
...
@yield('content')
...
【问题讨论】:
-
我们可以看看你的missing.blade.php
-
我在上面的编辑中添加了missing.blade.php 的内容。我在另一个文件中使用完全相同的布局没有问题(即@extends 和@section's)。
-
master.blade.php 请