当出现错误而不是抛出异常时,Laravel 5刀片显示空白页 [英] Laravel 5 blade shows a blank page when there is error instead of throwing exception

查看:404
本文介绍了当出现错误而不是抛出异常时,Laravel 5刀片显示空白页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在laravel 4中,当您尝试呈现在 app \views 中不存在的视图或具有未定义变量的视图时,laravel会抛出异常或显示有助于调试的错误。 p>

我有一个全新的laravel 5.0.13的安装,我很难对一个刀片模板进行故障排除,当我渲染一个不存在的视图或一个模板与未定义的变量,而不是抛出异常或错误,这将在调试时提示我。



我已经安装了filp / whoops:〜1.0。但仍然收到一个空白页

  class ProfileController extends Controller 
{

public function index ()
{
return view('indexx'); //这个视图不是真的存在
}
}

文件 indexx 不存在于我的资源/视图中,我希望Laravel抛出一个异常,但是改为空白页面,为什么?



此外,当我渲染一些存在于一些未定义变量的视图时,我只需获取一个空白页



示例:



class ProfileController extends Controller
{

  public function index()
{
return view('index'); //这个视图存在
}

}



资源/视图/索引的内容

  {! $ this_variable_was_not_passed_an_I_expect_error !!} 

正如你在上面的视图文件中可以看到的,变量不存在于laravel将简单地显示一个空白页面,而不是抛出异常或一些调试错误。



另外要注意,我在config / views中更改我的laravel默认视图

 'paths'=> [
// realpath(base_path('resources / views'))
realpath(base_path('resources / themes / default'))
],

只要模板中没有错误,laravel就可以从resources / themes / default中呈现视图,如果遇到任何错误这样的ar未定义的变量a laravel显示一个空白页,而不是显示错误消息



另外提到我在窗口7上安装虚拟框和流氓$



这可能是一个bug还是什么?请帮助。

解决方案

我不知道为什么会发生这种情况,



vagrant destroy 摧毁homestead VM



然后 vagrant up - 创建VM



错误消息现在已经显示,而不是空白页面:




In laravel 4 when you try to render a view that does not exists in app\views or a view with undefined variables laravel will throw an exception or show error that helps with debug.

I have a fresh installation of laravel 5.0.13 and am having a tough time troubleshooting a blade template that shows a blank page when i render a view that does not exists instead or a template with undefined variables instead of throwing an exception or error which will clue me in when debug.

I have installed filp/whoops:~1.0. but still recieve a blank page

class ProfileController extends Controller
{

    public function index()
    {
        return view('indexx'); //this view does not really exist
    }
}

The file indexx does not exist in my resources/views and i expect Laravel to throw an exception but am getting a blank page instead, why?

Also when i render a view that exists with some undefined variables i simply get a blank page

Example:

class ProfileController extends Controller {

    public function index()
    {
        return view('index'); //this view exists
    }

}

The content of resources/views/index

{!! $this_variable_was_not_passed_an_I_expect_error !!}

As you can see in the view file above the variable does not exist by laravel will simply show a blank page instead of throwing an exception or some debug error.

Also to note i change my laravel default view in config/views

'paths' => [ 
//realpath(base_path('resources/views')) 
realpath(base_path('resources/themes/default')) 
],

And laravel was able to render views from resources/themes/default as long as there is no error in the template however, if any error was encountered such ar undefined variable a laravel displays a blank page instead of showing error message

Also to mention that I install virtual box and vagrant on window 7

Could this be a bug or something? Please assist.

解决方案

I don't really know why this happened but its now working as required after i run

vagrant destroy to destroy homestead VM

and then vagrant up - to create the VM

The error messages has now showing up instead of blank page:

这篇关于当出现错误而不是抛出异常时,Laravel 5刀片显示空白页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆