Laravel blade debug view name on error

∥☆過路亽.° 提交于 2019-12-19 10:27:59

问题


when there is some error in view, L4 shows a nice trace, but cached filename: open: /var/www/webpage/app/storage/views/1154ef6ad153694fd0dbc90f28999013

howto during view-rendering-to-cache save view's path/name (in a comment or something)? Or better yet - to show it in the debug-error-page (its called whoops or something?)

Thanks ;)


回答1:


One way to tackle this problem is add a html comments (not blade ones as they will not be rendered in compiled view) in sections which get echoed.

@section('content)

<!-- FILE: app/views/main/index.blade.php -->

<Your Content Goes Here>

@stop

This html comment will get rendered in the compiled source of the view. Of course you will have to inspect the compiled view first to identify which view is the problematic one. But in my experience, this method work almost all the time.




回答2:


This is not exactly a problema, this is a compiled version of your view.

Laravel Blade System will compile all your views and subviews into a single file and, if you didn't change anything on them it will always try to use the compiled version, to speed up your system.

Sometimes is hard to know wich one of our views is related to that error. Using Sublime text, what I do is to hit CTRL-P (windows) and paste the number of the compiled view (1154ef6ad153694fd0dbc90f28999013) and it will bring it to me right away.

Of course, you won't do any changes on it. This is just way to find the view you have problems in, so you can then find the real file and fix it. If you know wich file is the problematic one, you don't have to do this, go directly to your file.




回答3:


I don't know how to de encrypt view names , but one method i do is to

{{dd('will you reach here ')}}

Trying to move this line from view to another to watch where php render reach .

I know it is not the right way nor the professional one , but it may help in some cases .




回答4:


I created a helper that checks to see if you are working locally or in development mode, It then outputs an HTML comment.

{{ printViewComment('mockup/reports@content') }}

<!-- Template: mockup/reports@content -->

I chose to name the comments like this path.file_name@yeild_name but I only wish this was an automated featured.




回答5:


I found my answer after looking into source, when on the Whoops! page, just look for render in the sidebar, there will be the name of the view file...



来源:https://stackoverflow.com/questions/19866123/laravel-blade-debug-view-name-on-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!