Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find exact error line in laravel 5.4 blade?

I know laravel caches blade files, and when there is an error in blade, in version 5.3 error would be something like this :

Undefined offset: 0 (View:b5c0ef4df49585eadd7fc1fa15b2d8a03e8c3bdd.php) line: 47

Then I can go to cached files and find the exact line,

But in version 5.4 laravel reference the exact blade file(not cached file) but without a line number! Something like this :

Undefined offset: 0 (View: C:\wamp64\www\project\resources\views\events\partial\event_details_members.blade.php)
in Collection.php (line 1537)

Now how to find the error?

UPDATE

I know where the problem is, and how to fix that, But I want Laravel to tell me this automatically whether I have to look for it manually. what if the blade file is very big?

like image 859
Ahmad Mobaraki Avatar asked Sep 22 '17 10:09

Ahmad Mobaraki


Video Answer


2 Answers

As of Laravel 5.7, the output shows stack frames on the left side and details of selected frame on right side. If you cruise through the stack, you'll find that one of the entries in there is the parsed version of your blade file (normally located near the (main) frame towards the bottom of the stack). Clicking this frame will take you to the exact line of the blade file that resulted in that exception.

enter image description here

like image 73
dotNET Avatar answered Oct 11 '22 10:10

dotNET


its not an easy way to find the error which raised in a cached view file.

but if your debug mode is off and you are going to find it out very quick,

I suggest this following steps:

I know this is not tidy.

1- find error in ./storage/laravel/log/today.log :

for example:

(b5c0ef4df49585eadd7fc1fa15b2d8a03e8c3bdd.php) (line : 47)

2- output the files content usng cat :

cat ./storage/framework/view/b5c0ef4df49585eadd7fc1fa15b2d8a03e8c3bdd.php

(file name from error log)

3- copy the content from terminal to an editor (from first line to the end)

4- you can find the buggy line.

like image 3
Abilogos Avatar answered Oct 11 '22 10:10

Abilogos