Laravel 刀片调试视图名称出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19866123/
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
Laravel blade debug view name on error
提问by Hontoni
when there is some error in view, L4 shows a nice trace, but cached filename: open: /var/www/webpage/app/storage/views/1154ef6ad153694fd0dbc90f28999013
当视图中出现一些错误时,L4 显示一个很好的跟踪,但缓存文件名:打开:/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?)
如何在视图渲染到缓存期间保存视图的路径/名称(在评论或其他内容中)?或者更好 - 在调试错误页面中显示它(它称为 whoops 什么的?)
Thanks ;)
谢谢 ;)
回答by Antonio Carlos Ribeiro
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.
Laravel Blade 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.
有时很难知道我们的哪个观点与该错误有关。使用 Sublime 文本,我要做的是点击 CTRL-P (windows) 并粘贴编译视图的编号 (1154ef6ad153694fd0dbc90f28999013),它会立即将它带给我。
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.
当然,您不会对其进行任何更改。这只是查找您遇到问题的视图的方法,因此您可以找到真正的文件并修复它。如果您知道 wich 文件是有问题的文件,则不必执行此操作,直接转到您的文件。
回答by tharumax
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.
解决此问题的一种方法是在得到回显的部分中添加html
注释(不是注释blade
,因为它们不会在编译视图中呈现)。
@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.
此 html 注释将在视图的编译源中呈现。当然,您必须首先检查编译后的视图,以确定哪个视图有问题。但根据我的经验,这种方法几乎一直有效。
回答by Hos Mercury
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 .
试图将这条线从视图移动到另一个视图以观察 php 渲染到达的位置。
I know it is not the right way nor the professional one , but it may help in some cases .
我知道这不是正确的方法,也不是专业的方法,但在某些情况下可能会有所帮助。
回答by Adam Patterson
I created a helper that checks to see if you are working locally or in development mode, It then outputs an HTML comment.
我创建了一个帮助程序来检查您是在本地工作还是在开发模式下工作,然后输出一个 HTML 注释。
{{ printViewComment('mockup/reports@content') }}
<!-- Template: mockup/reports@content -->
I chose to name the comments like this path.file_name@yeild_namebut I only wish this was an automated featured.
我选择像这样命名评论path.file_name@yeild_name但我只希望这是一个自动化的特色。
回答by Hontoni
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...
我在查看源代码后找到了我的答案,在 Whoops 上!页面,只要在侧边栏中寻找render,就会有视图文件的名称...